Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type of run signature #174

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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