Skip to content

[7.x backport] fix: avoid removable fields as decorator evaluation hosts - #18225

Open
nyan-left wants to merge 2 commits into
babel:7.xfrom
nyan-left:fix/7.x-decorators-erased-field-host
Open

[7.x backport] fix: avoid removable fields as decorator evaluation hosts#18225
nyan-left wants to merge 2 commits into
babel:7.xfrom
nyan-left:fix/7.x-decorators-erased-field-host

Conversation

@nyan-left

Copy link
Copy Markdown
Q A
Fixed Issues? Fixes #18223
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link N/A
Any Dependency Changes? No
License MIT

Backport of #18224.

On Babel 7, the TypeScript transform can remove uninitialized fields when allowDeclareFields is false. If one of those fields hosts a memoized decorator assignment, the assignment is removed with it and the generated class throws TypeError: A decorator must be a function.

This skips removable fields when selecting a host and uses the existing temporary computed field when necessary, and this is obviously going to solve the problem without changing decorator evaluation order.

Regression tests cover stacked member-expression decorators, class decorator ordering, and declaration fields using Babel 7's TypeScript behavior.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉

We really appreciate you taking the time to contribute, @nyan-left.

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description explains what changed and why
  • any related issues are linked
  • existing tests still pass

If anything needs adjusting we'll leave comments here. Thanks again!

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Insufficient data

Not enough activity yet to make a reliable assessment.

View full analysis →

This is an automated analysis by AgentScan

@babel-bot

babel-bot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: b17b76a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants