Skip to content

fix(decorators): replace super within all removed static elements#17931

Merged
JLHwung merged 3 commits into
babel:mainfrom
JLHwung:class-decorators-replace-super
Apr 21, 2026
Merged

fix(decorators): replace super within all removed static elements#17931
JLHwung merged 3 commits into
babel:mainfrom
JLHwung:class-decorators-replace-super

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Apr 13, 2026

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

In this PR we apply the ReplaceSuper step to all removed static class elements of a decorated class. Previously the ReplaceSuper step is only applied when a static private method contains instance private method. I believe back then this step was added merely because the test file happens to contain super property such as super.idB. They should be applied to all removed static elements because otherwise super will be resolved to the wrapper class.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Decorators labels Apr 13, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Apr 13, 2026

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 13, 2026

Open in StackBlitz

commit: d1239b5

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Can you also add a test where we make sure that the super method/getter is called with the correct this?

@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Apr 20, 2026

Can you also add a test where we make sure that the super method/getter is called with the correct this?

Added a new test, ptal.

@JLHwung JLHwung merged commit a7e6848 into babel:main Apr 21, 2026
101 of 102 checks passed
@JLHwung JLHwung deleted the class-decorators-replace-super branch April 21, 2026 00:24
nicolo-ribaudo pushed a commit to nicolo-ribaudo/babel that referenced this pull request Apr 24, 2026
nicolo-ribaudo pushed a commit to nicolo-ribaudo/babel that referenced this pull request Apr 24, 2026
nicolo-ribaudo pushed a commit to nicolo-ribaudo/babel that referenced this pull request Apr 24, 2026
JLHwung added a commit to nicolo-ribaudo/babel that referenced this pull request Apr 29, 2026
JLHwung added a commit to nicolo-ribaudo/babel that referenced this pull request Apr 30, 2026
JLHwung added a commit to nicolo-ribaudo/babel that referenced this pull request Apr 30, 2026
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 Spec: Decorators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@babel/plugin-proposal-decorators] static field with super reference incorrectly moved to wrapper class instance field (2023-11)

4 participants