Repository navigation
Conversation
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 17, 2026 10:57
d259f57 to
b3c7173
Compare
This was referenced Nov 17, 2026
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 19, 2026 03:28
b3c7173 to
f399480
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
2 times, most recently
from
November 19, 2026 16:00
944a6f1 to
078fca4
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 19, 2026 17:48
078fca4 to
aa06560
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
3 times, most recently
from
November 23, 2026 06:40
97d7416 to
e79783e
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 24, 2026 01:03
e79783e to
5327690
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 25, 2026 07:01
9de8de8 to
99029f4
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
2 times, most recently
from
November 25, 2026 07:19
aaf7da0 to
ee5fd45
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
2 times, most recently
from
November 25, 2026 10:58
e860b41 to
c7d8269
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
2 times, most recently
from
November 25, 2026 12:52
4e6e100 to
1b94c85
Compare
Dunqing
added a commit
to rolldown/rolldown
that referenced
this pull request
Nov 25, 2026
Patches every oxc crate to oxc-project/oxc@9e2856b2, the head of the stack that adds standard decorator and auto-accessor lowering (oxc-project/oxc#29749, oxc-project/oxc#29750, oxc-project/oxc#29751, oxc-project/oxc#28882). Drop the patch once an oxc release includes it. The stack sits on a newer oxc main, whose changes update some snapshots: - Legacy decorators: computed and assigned keys are passed to __decorate instead of null, and decorated static fields keep their decorators. - Source maps: calls whose callee is generated, such as a wrapped require(), init_*() or (0, x.f)(), map to their own source call instead of a neighbouring token (oxc-project/oxc#30204).
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 25, 2026 14:55
1b94c85 to
5a88f06
Compare
1 of 17 tasks
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 25, 2026 17:23
61f4ec6 to
594814c
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 25, 2026 17:54
09a9811 to
bc69557
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 26, 2026 02:03
bc69557 to
a75b3ae
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 26, 2026 02:05
a75b3ae to
e2cfe20
Compare
Dunqing
force-pushed
the
standard-decorators-evaluation
branch
from
November 26, 2026 02:41
e2cfe20 to
5a6051e
Compare
Dunqing
marked this pull request as ready for review
November 26, 2026 02:46
…he class References to a class inside its body, in its `extends` clause and through `export default` now see the class decorator's replacement. Writes to the immutable inner binding throw, and `super` in static elements resolves through the original class's parent, following the draft spec. A decorator such as `@a.b` is called with `this === a`. BREAKING CHANGE: TypeScript files with parameter decorators on class methods or constructors now fail with "Decorators are not valid here." (TS1206) unless legacy decorators are enabled.
This branch has not been deployed
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.
Stack 3/4 for standard (TC39 2023-11) decorators: class decorators that replace the class, and decorator
thisreceivers. #29750 already calls class decorators and stores the replacement; this PR makes everything that refers to the class see the right value afterwards:K = x,K &&= x, destructuring,for-of) throw aTypeError, keeping evaluation order.@rep class A extends mk(() => A) {},() => Areturns the replacement, while a direct read is still in the TDZ.export default @dec class Foo {}becomesexport { Foo as default }, a live binding.@a.b.cis called withthis === a.b.superin static elements resolves through the original class's parent (draft behaviour).Example
Input:
Output with
decorator: { lower: true }at es2022 (abridged;babelHelpers.*stands for the@oxc-project/runtimehelpers):Both
_Aand_A2are updated when the class decorator returns a replacement, so code moved out of the body (static self = Areads_A2) and the outer binding (let A = _A) see it. Static fields are installed on the replacement afterwards. No playground link: the released playground doesn't lower standard decorators.Class replacement semantics
The proposal is at Stage 2.7 since May 2026 (meeting notes), and Test262 has no semantic tests for it. Oxc follows the draft text in tc39/ecma262#2417 (2024-02-02); Babel and esbuild differ from it for static elements. Here
Fis the original class andnewFthe replacement:thissuperthisnewF.#m()newFF's parentnewFnewFnewF's parentFFornewFnewFOnly the draft's
superworks when a decorator wraps the class asclass extends C; with Babel,static x = super.who()gets the class's ownwho(). esbuild's fieldthisisFwhen only the class is decorated, because it then leaves static fields in the class body. Static private methods are an open question in the draft, which installs them onFbut static private fields onnewF; Oxc keeps the draft. The full write-up is in the module doc ofdecorator/standard/mod.rs.Breaking change
TypeScript parameter decorators on class methods or constructors (
m(@d x)) now fail with "Decorators are not valid here." (TS1206) unless legacy decorators are enabled; before, the output keptm(@d x), which is not valid JavaScript. Projects that use them (NestJS, TypeORM, Angular DI) should setdecorator: { legacy: true }, matchingexperimentalDecorators. The parser already reported JavaScript files and other functions' parameters.The benchmarks and
cargo allocsnow transformkitchen-sink.tsx, which has parameter decorators, with legacy decorators as its header specifies, so its allocation counts change with the workload (arena 6132 → 6917, system 185 → 238), not from a slowdown.Transformer tests, clippy and transform conformance with execution pass. Compared with #29750: Babel output 766/1208 unchanged, Oxc output 378 → 383/503, Oxc execution 421 → 453/455, and Babel execution 496 → 495/602: three receiver and outer-binding fixtures now pass, and four
replacement-static-{block,property}-superfixtures fail by design, because they resolvesuperthrough the replacement class. The other 13 class-replacement failures assert Babel's semantics from the table above, and four more stop on syntax or options Oxc doesn't support: Babel's private destructuring ({ #x: x }) and theignoreFunctionLengthassumption, which object-rest-spread doesn't implement.misc--to-es2015-outer-class-binding-mutatedstill fails: that copy asserts Babel's missing class TDZ, and the native copy passes.Depends on #29750. Part of #9170.
AI disclosure: implemented and described with AI assistance; this revision was written with Claude Code (Claude Opus 5.5; reasoning effort not recorded).