Skip to content

Improve @babel/parser AST types - #16425

Merged
nicolo-ribaudo merged 5 commits into
babel:mainfrom
nicolo-ribaudo:improve-parser-types
Apr 22, 2024
Merged

nicolo-ribaudo merged 5 commits into
babel:mainfrom
nicolo-ribaudo:improve-parser-types

Conversation

@nicolo-ribaudo

Copy link
Copy Markdown
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

babel-bot commented Apr 12, 2024

Copy link
Copy Markdown
Collaborator

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

@liuxingbaoyu liuxingbaoyu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

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
@nicolo-ribaudo
nicolo-ribaudo deleted the improve-parser-types branch April 22, 2024 15:21
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 23, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue 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.

4 participants