Skip to content

Commit

Permalink
Fix type of run signature
Browse files Browse the repository at this point in the history
Closes GH-173.
Closes GH-174.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
alvinleung1996 authored Nov 18, 2021
1 parent c3ba2cd commit 6b060c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export interface FrozenProcessor<
* Promise that resolves to the resulting tree.
*/
run(
node: Specific<Node, CompileTree>,
node: Specific<Node, ParseTree>,
file?: VFileCompatible | undefined
): Promise<Specific<Node, CompileTree>>

Expand Down
6 changes: 6 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,19 @@ expectType<VFile & {result: ReactNode}>(
)

// A parser plugin defines the input of `.run`:
expectType<Promise<MdastRoot>>(unified().use(remarkParse).run(someMdast))
expectType<MdastRoot>(unified().use(remarkParse).runSync(someMdast))
expectError(unified().use(remarkParse).run(someHast))
expectError(unified().use(remarkParse).runSync(someHast))

// A compiler plugin defines the input/output of `.run`:
expectError(unified().use(rehypeStringify).run(someMdast))
expectError(unified().use(rehypeStringify).runSync(someMdast))
// As a parser and a compiler are set, it can be assumed that the input of `run`
// is the result of the parser, and the output is the input of the compiler.
expectType<Promise<HastRoot>>(
unified().use(remarkParse).use(rehypeStringify).run(someMdast)
)
expectType<HastRoot>(
unified().use(remarkParse).use(rehypeStringify).runSync(someMdast)
)
Expand Down

0 comments on commit 6b060c2

Please sign in to comment.