Skip to content

Comments

fix(decorators): fix private decorator regressions (issue #9565)#11563

Closed
kdy1 wants to merge 2 commits intomainfrom
kdy1/fix-issue-9565-decorators-private-fields
Closed

fix(decorators): fix private decorator regressions (issue #9565)#11563
kdy1 wants to merge 2 commits intomainfrom
kdy1/fix-issue-9565-decorators-private-fields

Conversation

@kdy1
Copy link
Member

@kdy1 kdy1 commented Feb 19, 2026

Summary

  • fix initProto injection so it is not inserted into private field initializers
  • preserve decorator expressions that reference private names (for example, a.#log) instead of hoisting them outside class scope
  • replace ignored fixture-style exec coverage for this issue with explicit execution tests in crates/swc/tests/exec.rs using decoratorVersion 2022-03

Tests

  • cargo test -p swc --test exec issue_9565
  • cargo test -p swc_ecma_transforms_proposal
  • cargo test -p swc
  • cargo fmt --all
  • cargo clippy --all --all-targets -- -D warnings (fails in this checkout due missing test262-parser/pass fixture set in swc_ecma_codegen tests)

Closes #9565

github-actions bot and others added 2 commits February 18, 2026 19:12
This fixes issue #9565 where decorators on private fields were not
working correctly. The main problem was that `_initProto` was being
injected into private field initializers, causing `addInitializer`
callbacks to fail when they tried to access private fields.

The fix ensures `_initProto(this)` is only injected into public field
initializers or the constructor, not into private field initializers.
This is because private fields are not accessible until their
initializer has completed, so any `addInitializer` callback that
tries to access a private field during its own initialization would
fail.

Closes #9565

Co-authored-by: Donny/강동윤 <[email protected]>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ kdy1
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

⚠️ No Changeset found

Latest commit: b4ee504

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (28581832 bytes)

Commit: e72f9de

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 19, 2026

Merging this PR will not alter performance

✅ 184 untouched benchmarks


Comparing kdy1/fix-issue-9565-decorators-private-fields (b4ee504) with main (431c576)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (638d7ce) during the generation of this report, so 431c576 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@kdy1 kdy1 closed this Feb 23, 2026
@kdy1 kdy1 deleted the kdy1/fix-issue-9565-decorators-private-fields branch February 23, 2026 03:24
@github-actions github-actions bot modified the milestones: Planned, 1.15.13 Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Decorators cannot work with private fields

2 participants