Repository navigation
fix(transformer/typescript): hide computed key methods from decorators - #30184
Merged
Dunqing merged 1 commit intoNov 24, 2026
Conversation
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
Dunqing
marked this pull request as ready for review
November 24, 2026 16:29
Contributor
Monitor OxcCommit:
|
Dunqing
added a commit
to rolldown/rolldown
that referenced
this pull request
Nov 24, 2026
Pins the restacked decorators-lowering head, now on oxc main 1abb96db. Snapshot changes: - Legacy decorator fixtures pick up main's fixes: computed and assigned keys are passed to __decorate instead of null, and decorated static fields keep their decorators (oxc-project/oxc#29979, oxc-project/oxc#30148, oxc-project/oxc#30184). - Generated calls whose callee has no source position now map to the call itself, so wrapped require(), init_*() and (0, x.f)() calls point at their source call rather than a neighbouring token. - _decoratorStart and _decorateElement now map to the class and to each decorated element, so a throwing decorator's frame lands on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A standard element decorator can inspect the class before its static blocks run. With
setPublicClassFieldsenabled, it can see the symbol-keyed method that #30148 generates to evaluate a computed key. The source class has no such property.Example
The Oxc playground cannot run the downstream decorator pass that exposes the extra symbol. To print the JavaScript locally, save the input as
/tmp/repro.tsand run the transformer example with the fixture options.fixture=tasks/transform_conformance/tests/babel-plugin-transform-typescript/test/fixtures/oxc/preserved-class-context-dependent-computed-keys cargo run -p oxc_transformer --example transformer -- /tmp/repro.ts --babel-options "$fixture/options.json"Before, the generated method and cleanup were visible in the output.
After, the key runs in a decorator expression on a private method.
The generator still yields
"key", and the static field receives1. With Babel 2023-11 and esbuild, the inspecting decorator saw one extra symbol before and zero after. The runtime fixture also exercises a user-defined symbol and enclosing private names accessed directly and througheval.The focused runtime result is
Passed: 1 of 1. Transformer tests and lint passed. Transformer coverage snapshots matched, and full transform conformance recorded one additional passing Oxc exec fixture.AI disclosure: prepared with AI assistance. The exact model version and reasoning effort were not recorded.