Skip to content

fix: avoid removable fields as decorator evaluation hosts - #18224

Open
nyan-left wants to merge 2 commits into
babel:mainfrom
nyan-left:fix/decorators-erased-field-host
Open

nyan-left wants to merge 2 commits into
babel:mainfrom
nyan-left:fix/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

Decorator memoization can be attached to a class field that a later transform removes, causing the generated class to throw 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 uninitialized and declaration fields.

@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/62305

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: a580836

@JLHwung

JLHwung commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

You have violated the AI policy of the Babel project without a declaimer that this PR is generated by LLM.

@nyan-left

Copy link
Copy Markdown
Author

You have violated the AI policy of the Babel project without a declaimer that this PR is generated by LLM.

Fair. I marked the LLM assistance on the issue but not here. I've now read the AI policy properly. PR descriptions have to be my own writing, a disclaimer wouldn't have covered it either way.

How do you want to handle it? I can rewrite the description and the tests by hand, or close this and leave the issue up with the repro. Either is fine, your call.

@nyan-left
nyan-left deleted the fix/decorators-erased-field-host branch September 30, 2026 14:30
@nyan-left

Copy link
Copy Markdown
Author

@nicolo-ribaudo I was clearly trying to sort this out. I owned up to it and asked how maintainers wanted to handle it. Even offered to rewrite the description and tests myself. Three weeks of nothing, then a label and a close without a word. If closing it was the answer, a one line reply would have done it.

Kind of ridiculous when the fix is sitting right there and it's easy to follow. If you want to fix it yourselves and cherry-pick the exact same code, feel free.

I've patched it locally anyway and I'm moving off Babel as soon as I can.

@nicolo-ribaudo

Copy link
Copy Markdown
Member

Sorry about that, I was going through PRs to close and didn't notice that this was pending on us to reply.

There is clearly enough human involvement on your side, I'll review.

@nicolo-ribaudo

Copy link
Copy Markdown
Member

Any chance you could restore the branch so that I can reopen the PR, or can you re-submit it?

@nyan-left

Copy link
Copy Markdown
Author

@nicolo-ribaur

It's okay. Will restore tomorrow AM, once I'm back at my desk. Thanks.

@nyan-left
nyan-left restored the fix/decorators-erased-field-host branch October 1, 2026 12:05
@nyan-left

Copy link
Copy Markdown
Author

Hey @nicolo-ribaudo , that has been restored. LMK if you'd like the tests rewritten/tweaked or if you have any other feedback. Thank you.

@nicolo-ribaudo nicolo-ribaudo left a comment

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.

Thank you! Can you also add input/output tests next to the exec ones?

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Oct 6, 2026
@nicolo-ribaudo

Copy link
Copy Markdown
Member

Btw, do you need this PR backported to v7 also?

@nyan-left

nyan-left commented Oct 6, 2026 •

Copy link
Copy Markdown
Author

Yeah, we're using v7. Restored the branch on that PR. #18225

@nicolo-ribaudo nicolo-ribaudo left a comment

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.

Looks good, thanks!

This branch has not been deployed

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

Labels

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.

Decorators throw when TypeScript removes their memoization host field

4 participants