Skip to content

refactor(parser): use AST definitions from babel/types#17853

Merged
nicolo-ribaudo merged 4 commits intobabel:mainfrom
JLHwung:use-ast-types-in-babel-parser
Mar 12, 2026
Merged

refactor(parser): use AST definitions from babel/types#17853
nicolo-ribaudo merged 4 commits intobabel:mainfrom
JLHwung:use-ast-types-in-babel-parser

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Mar 5, 2026

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

This PR includes commits from #17852, please review that PR first.

As a follow-up to #14783, in this PR we use @babel/types AST definitions to type @babel/parser. The @babel/parser types now only includes a few custom alias and ESTree AST shapes.

I have disabled a few typing errors because in general @babel/parser is more tolerant than the @babel/types AST definitions due to the error recovery: It is possible that we assign nonexistent properties such that we can emit a recoverable error.

There are also a few typing errors that points to incorrect parser behaviour. For the time being they are left as-is pending further investigation. So this PR is a refactor that aims for zero behaviour change.

@JLHwung JLHwung added the PR: Internal (next major) 🏠 A type of pull request used for our changelog categories for next major release label Mar 5, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Mar 5, 2026

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 5, 2026

Open in StackBlitz

commit: 105494a

@JLHwung JLHwung marked this pull request as ready for review March 5, 2026 14:20
@JLHwung JLHwung requested a review from liuxingbaoyu March 5, 2026 14:20
@JLHwung JLHwung force-pushed the use-ast-types-in-babel-parser branch 4 times, most recently from fef6de8 to 21f7ec1 Compare March 5, 2026 16:27
@nicolo-ribaudo
Copy link
Copy Markdown
Member

Could you rebase? :)

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Mar 7, 2026
@liuxingbaoyu liuxingbaoyu force-pushed the use-ast-types-in-babel-parser branch from 21f7ec1 to c581ae7 Compare March 8, 2026 00:47
@JLHwung JLHwung force-pushed the use-ast-types-in-babel-parser branch from c581ae7 to 2027129 Compare March 8, 2026 12:40
@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Mar 8, 2026

@liuxingbaoyu Thank you for rebasing. I removed the first two commits as they were included in #17852.

@JLHwung JLHwung force-pushed the use-ast-types-in-babel-parser branch from 2027129 to 83f956a Compare March 11, 2026 14:44
@JLHwung JLHwung force-pushed the use-ast-types-in-babel-parser branch from 83f956a to 105494a Compare March 11, 2026 18:20
@nicolo-ribaudo nicolo-ribaudo merged commit 46204ac into babel:main Mar 12, 2026
56 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the use-ast-types-in-babel-parser branch March 12, 2026 09:43
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 PR: Internal (next major) 🏠 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants