Skip to content

Commit 6b060c2

Browse files
Fix type of run signature
Closes GH-173. Closes GH-174. Reviewed-by: Titus Wormer <[email protected]> Reviewed-by: Christian Murphy <[email protected]>
1 parent c3ba2cd commit 6b060c2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export interface FrozenProcessor<
316316
* Promise that resolves to the resulting tree.
317317
*/
318318
run(
319-
node: Specific<Node, CompileTree>,
319+
node: Specific<Node, ParseTree>,
320320
file?: VFileCompatible | undefined
321321
): Promise<Specific<Node, CompileTree>>
322322

index.test-d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,19 @@ expectType<VFile & {result: ReactNode}>(
360360
)
361361

362362
// A parser plugin defines the input of `.run`:
363+
expectType<Promise<MdastRoot>>(unified().use(remarkParse).run(someMdast))
363364
expectType<MdastRoot>(unified().use(remarkParse).runSync(someMdast))
365+
expectError(unified().use(remarkParse).run(someHast))
364366
expectError(unified().use(remarkParse).runSync(someHast))
365367

366368
// A compiler plugin defines the input/output of `.run`:
369+
expectError(unified().use(rehypeStringify).run(someMdast))
367370
expectError(unified().use(rehypeStringify).runSync(someMdast))
368371
// As a parser and a compiler are set, it can be assumed that the input of `run`
369372
// is the result of the parser, and the output is the input of the compiler.
373+
expectType<Promise<HastRoot>>(
374+
unified().use(remarkParse).use(rehypeStringify).run(someMdast)
375+
)
370376
expectType<HastRoot>(
371377
unified().use(remarkParse).use(rehypeStringify).runSync(someMdast)
372378
)

0 commit comments

Comments
 (0)