Skip to content

Make ArrowFunctionExpression.expression optional#17885

Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom
liuxingbaoyu:remove-arrow-expression
Apr 17, 2026
Merged

Make ArrowFunctionExpression.expression optional#17885
nicolo-ribaudo merged 1 commit intobabel:mainfrom
liuxingbaoyu:remove-arrow-expression

Conversation

@liuxingbaoyu
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

This property only exists when the flow or estree plugin is enabled.

@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Mar 18, 2026

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

@liuxingbaoyu
Copy link
Copy Markdown
Member Author

I'm not sure how we handle flow types, perhaps keep it optional?

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 18, 2026

Open in StackBlitz

commit: 602170b

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

Aside: we should also remove method: boolean from ObjectMember.

@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 18, 2026
@JLHwung
Copy link
Copy Markdown
Contributor

JLHwung commented Mar 18, 2026

The flow parser seems to always set this property.

Right, didn't you just mention that the expression property will be set when the flow option is enabled? So the AST does align with the flow.

@liuxingbaoyu
Copy link
Copy Markdown
Member Author

Oh, I understand what you mean.

Will we preserve the flow property in the @babel/types definition? ArrowFunctionExpression.predicate is also a property specific to flow.
If we're going to keep them, perhaps we could make expression optional in @babel/types instead of removing it.

@JLHwung
Copy link
Copy Markdown
Contributor

JLHwung commented Mar 18, 2026

Will we preserve the flow property in the @babel/types definition?

Yes, we don't plan to drop flow support on Babel 8.

make expression optional in @babel/types instead of removing it.

That sounds good to me. We can just remove the manual sync part as long as current logic does not depend on the expression property.

@liuxingbaoyu liuxingbaoyu force-pushed the remove-arrow-expression branch from 5fc298f to 602170b Compare March 19, 2026 20:38
@liuxingbaoyu liuxingbaoyu changed the title Remove expression from ArrowFunctionExpression Set optional for ArrowFunctionExpression.expression Mar 19, 2026
@liuxingbaoyu liuxingbaoyu added PR: Spec Compliance 👓 A type of pull request used for our changelog categories pkg: types and removed PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Mar 19, 2026
@nicolo-ribaudo nicolo-ribaudo added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release and removed PR: Spec Compliance 👓 A type of pull request used for our changelog categories labels Apr 17, 2026
@nicolo-ribaudo nicolo-ribaudo changed the title Set optional for ArrowFunctionExpression.expression Make ArrowFunctionExpression.expression optional Apr 17, 2026
@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories and removed PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release labels Apr 17, 2026
@nicolo-ribaudo
Copy link
Copy Markdown
Member

Marking this as a bugfix because we already do not generate .expression by default. This is just updating @babel/types to reflect that.

@nicolo-ribaudo nicolo-ribaudo merged commit cf55b5d into babel:main Apr 17, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: types PR: Bug Fix 🐛 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