Fix(types): Align AST definitions to parser implementations#17852
Merged
nicolo-ribaudo merged 7 commits intobabel:mainfrom Mar 7, 2026
Merged
Fix(types): Align AST definitions to parser implementations#17852nicolo-ribaudo merged 7 commits intobabel:mainfrom
nicolo-ribaudo merged 7 commits intobabel:mainfrom
Conversation
This node was introduced in babel#10091 but we forgot to add the babel-types definition
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61116 |
|
commit: |
b6b5cba to
7a04424
Compare
7a04424 to
2779dd3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@babel/typesThis PR is extracted from (todo).
In this PR we aligns the AST definitions in
@babel/typesto the actual@babel/parserbehaviour. The following changes are implemented:BigIntLiteralTypeAnnotationtype definition. This AST type was introduced in BigInt type for Flow #10091 but we forgot to add the babel-types definitionTSInterfaceDeclarationandEnumDeclarationunderExportDefaultDeclarationextendstype ofTSInterfaceDeclarationfromTSClassImplements[]toTSInterfaceHeritage[]. The parser always generatesTSInterfaceHeritageso this is a definition error. SinceTSInterfaceHeritageis introduced in Babel 8, we can fix it before 8.0.0kindofTSModuleDeclarationto bemoduleobjectofBindExpressionto benull. This AST models the production:: MemberExpression[?Yield]keyofObjectTypePropertyto beNumericLiteral. Flow allowstype A = { 0: string }but it does not support bigInt as object type key yetvaluetype ofDeclaredPredicatefromFlowtoExpression. It is formed bysuper.parseExpression. BTW Flow has removed the support of predicate syntaxpredicatetype ofDeclareFunctionto beInferredPredicate. Both Babel and Flow parser supportdeclare function f(): boolean %checksthough Flow will emit an error that the syntax is unsupported and will be ignored