Skip to content

[Babel 8] Remove Import from the Expression alias#17867

Merged
JLHwung merged 6 commits intobabel:mainfrom
JLHwung:fix-babel-types-definitions
Mar 13, 2026
Merged

[Babel 8] Remove Import from the Expression alias#17867
JLHwung merged 6 commits intobabel:mainfrom
JLHwung:fix-babel-types-definitions

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Mar 12, 2026

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

Similar to #14750, in this PR we remove Import from the Expression alias. In Babel 8 the Import node will only be generated when createImportExpressions is false, so this change should has less impact than the Super one.

This PR also refines the accepted node types in ExportNamedDeclaration#declaration, allows PrivateName as the key of the OptionalMemberExpression and introduces a few union types improvements.

@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Mar 12, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Mar 12, 2026

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

} satisfies ValidatorImpl,
{ oneOfNodeTypes: ["Declaration"] as const },
{
oneOfNodeTypes: [
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.

What is the change here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change is from the first commit.

Here we align with the current parser behaviour and disallow the following nodes (not a complete list) within the ExportNamedDeclaration:

  • ExportDeclaration
  • ImportDeclaration
  • DeclareClass (forms DeclareExportDeclaration)
  • DeclareFunction (forms DeclareExportDeclaration)

@JLHwung JLHwung force-pushed the fix-babel-types-definitions branch from 7138440 to 210311d Compare March 12, 2026 20:25
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 12, 2026

Open in StackBlitz

commit: 210311d

@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Mar 13, 2026

Docs PR is ready: babel/website#3188, PTAL.

@JLHwung JLHwung merged commit 17b56f2 into babel:main Mar 13, 2026
56 checks passed
@JLHwung JLHwung deleted the fix-babel-types-definitions branch March 13, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Breaking Change 💥 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