Commit edae309 1 parent 4f33040 commit edae309 Copy full SHA for edae309
File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ const markedInstance = new Marked();
26
26
export function marked ( src : string , options : MarkedOptions & { async : true } ) : Promise < string > ;
27
27
28
28
/**
29
- * Compiles markdown to HTML synchronously .
29
+ * Compiles markdown to HTML.
30
30
*
31
31
* @param src String of markdown source to be compiled
32
32
* @param options Optional hash of options
33
- * @return String of compiled HTML
33
+ * @return String of compiled HTML. Wil be a Promise of string if async is set to true by any extensions.
34
34
*/
35
- export function marked ( src : string , options ?: MarkedOptions ) : string ;
35
+ export function marked ( src : string , options ?: MarkedOptions ) : string | Promise < string > ;
36
36
export function marked ( src : string , opt ?: MarkedOptions ) : string | Promise < string > {
37
37
return markedInstance . parse ( src , opt ) ;
38
38
}
Original file line number Diff line number Diff line change @@ -247,13 +247,21 @@ marked.use(asyncExtension);
247
247
const md = '# foobar' ;
248
248
const asyncMarked : string = await marked ( md , { async : true } ) ;
249
249
const promiseMarked : Promise < string > = marked ( md , { async : true } ) ;
250
+ // @ts -expect-error marked can still be async if an extension sets `async: true`
250
251
const notAsyncMarked : string = marked ( md , { async : false } ) ;
252
+ // @ts -expect-error marked can still be async if an extension sets `async: true`
251
253
const defaultMarked : string = marked ( md ) ;
254
+ // as string can be used if no extensions set `async: true`
255
+ const stringMarked : string = marked ( md ) as string ;
252
256
253
257
const asyncMarkedParse : string = await marked . parse ( md , { async : true } ) ;
254
258
const promiseMarkedParse : Promise < string > = marked . parse ( md , { async : true } ) ;
259
+ // @ts -expect-error marked can still be async if an extension sets `async: true`
255
260
const notAsyncMarkedParse : string = marked . parse ( md , { async : false } ) ;
261
+ // @ts -expect-error marked can still be async if an extension sets `async: true`
256
262
const defaultMarkedParse : string = marked . parse ( md ) ;
263
+ // as string can be used if no extensions set `async: true`
264
+ const stringMarkedParse : string = marked . parse ( md ) as string ;
257
265
} ) ( ) ;
258
266
259
267
// Tests for List and ListItem
You can’t perform that action at this time.
0 commit comments