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

3rd overload signature of FrozenProcessor.run should accept ParseTree instead of CompileTree #173

Closed
4 tasks done
alvinleung1996 opened this issue Nov 17, 2021 · 5 comments · Fixed by #174
Closed
4 tasks done
Labels
💪 phase/solved Post is done

Comments

@alvinleung1996
Copy link
Contributor

Initial checklist

Affected packages and versions

unified 10.1.0

Link to runnable example

No response

Steps to reproduce

The 3rd overload signature of FrozenProcessor.run is incorrect.

unified/index.d.ts

Lines 307 to 321 in c3ba2cd

/**
* Run transforms on the given node.
*
* @param node
* Tree to transform.
* @param file
* File associated with `node`.
* `VFile` or anything that can be given to `new VFile()`.
* @returns
* Promise that resolves to the resulting tree.
*/
run(
node: Specific<Node, CompileTree>,
file?: VFileCompatible | undefined
): Promise<Specific<Node, CompileTree>>

Expected behavior

run(
    node: Specific<Node, ParseTree>,
    file?: VFileCompatible | undefined
): Promise<Specific<Node, CompileTree>>

Actual behavior

run(
    node: Specific<Node, CompileTree>,
    file?: VFileCompatible | undefined
): Promise<Specific<Node, CompileTree>>

Runtime

Node v16

Package manager

Other (please specify in steps to reproduce)

OS

Linux

Build and bundle tools

Webpack

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Nov 17, 2021
@wooorm
Copy link
Member

wooorm commented Nov 17, 2021

Why? ParseTree is the input tree. CompileTree is the output tree.

@ChristianMurphy
Copy link
Member

I'd second the why question.
@alvinleung1996 do you have an example where an input or output which should be supported, is not supported?

@alvinleung1996
Copy link
Contributor Author

Why? ParseTree is the input tree. CompileTree is the output tree.

For the first and second overload, ParseTree is the input tree and CompileTree is the output tree. But for the third one, CompileTree is the input tree and CompileTree is the output tree, which is inconsistent with the first two overloads and is incorrect.

unified/index.d.ts

Lines 273 to 321 in c3ba2cd

/**
* Run transforms on the given tree.
*
* @param node
* Tree to transform.
* @param callback
* Callback called with an error or the resulting node.
* @returns
* Nothing.
*/
run(
node: Specific<Node, ParseTree>,
callback: RunCallback<Specific<Node, CompileTree>>
): void
/**
* Run transforms on the given node.
*
* @param node
* Tree to transform.
* @param file
* File associated with `node`.
* `VFile` or anything that can be given to `new VFile()`.
* @param callback
* Callback called with an error or the resulting node.
* @returns
* Nothing.
*/
run(
node: Specific<Node, ParseTree>,
file: VFileCompatible | undefined,
callback: RunCallback<Specific<Node, CompileTree>>
): void
/**
* Run transforms on the given node.
*
* @param node
* Tree to transform.
* @param file
* File associated with `node`.
* `VFile` or anything that can be given to `new VFile()`.
* @returns
* Promise that resolves to the resulting tree.
*/
run(
node: Specific<Node, CompileTree>,
file?: VFileCompatible | undefined
): Promise<Specific<Node, CompileTree>>

@wooorm
Copy link
Member

wooorm commented Nov 18, 2021

Ah, I misunderstood. Thanks for clarifying!
I think you’re right. Care to create a pull request solving it?

@alvinleung1996
Copy link
Contributor Author

Ah, I misunderstood. Thanks for clarifying! I think you’re right. Care to create a pull request solving it?

OK, I will create a pull request for it.

wooorm pushed a commit that referenced this issue Nov 18, 2021
Closes GH-173.
Closes GH-174.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
@wooorm wooorm added the 💪 phase/solved Post is done label Nov 18, 2021
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

Successfully merging a pull request may close this issue.

3 participants