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

Improve @babel/parser AST types #16425

Merged
merged 5 commits into from Apr 22, 2024

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@babel/parser's AST types used Node as a base class for every node, effectively making it equivalent to "any" for nodes (since it had type: string). This PR replaces it with a proper union of all the possible nodes, like we do in @babel/parser.

I was experimenting with merging our type definitions in @babel/parser, and @babel/types, but it might not be possible because:

  • @babel/parser has more nodes (ESTree, placeholders)
  • @babel/types has node locations as optional

I will still try to add a test to assert that the types are samewhat compatible, in a future PR.

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Apr 12, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented Apr 12, 2024

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56742

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the CI error has been fixed in main, can you rebase?

@nicolo-ribaudo nicolo-ribaudo merged commit 941cee2 into babel:main Apr 22, 2024
50 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the improve-parser-types branch April 22, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: parser PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants