Repository navigation
Conversation
The `accessor` keyword (TC39 auto-accessors / TypeScript 4.9+) was gated behind the internal `standard_decorators` feature flag, so any class field written as `public accessor foo: number` failed to parse when a project's tsconfig.json had `experimentalDecorators: true` — a common default in Angular-style projects. TypeScript accepts `accessor` in both decorator modes (they're independent proposals), so remove the gate. The lowering side already handles undecorated `auto_accessor` properties (WeakMap + getter/setter pair); we just need `should_lower_standard_decorators` to fire whenever an auto-accessor is present, regardless of whether any other members are decorated. Combining `accessor` with TS legacy `@dec` in the same class would route the legacy decorators through the standard-proposal runtime (wrong signature, wrong semantics). Emit a clear compile-time error for that case rather than silently miscompiling. Closes #29553
|
Updated 2:11 PM PT - Apr 21st, 2026
❌ @autofix-ci[bot], your commit b55e4dd has 2 failures in
🧪 To try this PR locally: bunx bun-pr 29554That installs a local version of the PR into your bun-29554 --bun |
|
Found 3 issues this PR may fix:
🤖 Generated with Claude Code |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughParser recognizes Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Thanks — this is related to but not the same as #29201 / #26431.
If the comprehensive path in #29201 lands first, this PR should be closed. If #29201 stays stuck, this one unblocks the reported issues (#29553 and #27335) while leaving the mixed case as a surfaced "not supported" error instead of a silent miscompile. |
There was a problem hiding this comment.
LGTM — the fix correctly threads accessor lowering through the existing WeakMap+getter/setter path by setting should_lower_standard_decorators whenever has_auto_accessor is true, regardless of decorator mode.
Extended reasoning...
Overview
Two small Zig changes and a new regression test file. parseProperty.zig drops the standard_decorators feature guard on the p_accessor branch so the keyword is accepted in class bodies under either decorator mode. parse.zig adjusts the should_lower_standard_decorators condition to has_auto_accessor or (standard_decorators and has_any_decorators) and adds a diagnostic for the mixed legacy-decorator + accessor case.
Security risks
None. This is a parser fix with no auth, crypto, or permissions code involved.
Level of scrutiny
Low-to-medium. The change is small and self-contained: one boolean condition in the property parser, one boolean condition in the class-body assembler, and one new error path. The existing lowerDecorators.zig already has the undecorated auto-accessor lowering path (WeakMap + getter/setter, line ~820), so no new lowering logic is introduced — the fix just ensures the right code path is reached. Five targeted regression tests cover the main scenario, modifier variants, no-tsconfig baseline, standard-decorator regression guard, and the new error case.
Other factors
The PR description notes that 209 tests across nearby decorator suites continue to pass. The mixed-mode error is a conservative safety net: rather than silently mis-route legacy decorators through the standard-proposal runtime, it rejects the combination with a clear diagnostic. That tradeoff is appropriate.
|
CI failures on
The regression test added here ( |
|
Yep — #29201 is the more comprehensive fix; this is a minimal subset. Breakdown: #29201 (my earlier branch, 807+/10-, 4 files, 10 days old,
#29554 (this PR, 116+/3-, 3 files):
Trade-off is narrow: #29553 and #27335 fully fixed by either, but #29201 supports decorated accessors under Happy with either landing. If you want the comprehensive one, #29201 needs a rebase onto current main (branch is 10d old) and the CodeRabbit threads addressed — I can do that on top of this. If you want the minimal path forward for now, this is ready and gate-verified. |
|
Should we close this? What is more correct? |
|
Honest take: #29201 is more correct, close this. TypeScript compiles For the issue at hand (#29553), both work. For #29197 ( I’ll rebase #29201 onto current main, address the 4 open CodeRabbit threads (mostly |
|
Closing in favor of #29201 — rebased onto current main, squashed the 13 commits into one clean diff, reworded the commit message, and verified locally:
|
What
Fixes #29553. Fixes #27335. The
accessorkeyword (TC39 auto-accessors, TypeScript 4.9+) was gated behind the internalstandard_decoratorsfeature flag in the parser, so any class field written aspublic accessor foo: numberfailed to parse when a project'stsconfig.jsonhadexperimentalDecorators: true— a common default, especially in Angular-style projects.Why
TypeScript accepts
accessorin both decorator modes — they're independent proposals. The lowering path inlowerDecorators.zigalready handles undecoratedauto_accessorproperties (WeakMap + getter/setter pair). All that was missing was the parser gate and theshould_lower_standard_decoratorscondition.How
p.options.features.standard_decoratorsguard on thep_accessorkeyword branch. Always recogniseaccessorin class bodies.should_lower_standard_decoratorswhenever an auto-accessor is present (not only whenstandard_decoratorsis already on), so the accessor gets lowered correctly. JavaScriptCore doesn't parseaccessornatively, so the rewrite is what makes it run.accessorwith TS legacy@decmembers underexperimentalDecorators: true, emit a clear compile error. Otherwise the legacy decorators would be routed through the standard-proposal runtime (wrong signature), which is worse than a clear error.Verification
test/regression/issue/29553.test.ts— 5 tests covering:bun test ./testwithexperimentalDecorators: true).accessorwith all TS modifiers (public,private,protected,static,readonly) underexperimentalDecorators: true.accessorin a plain TS file (no tsconfig).accessorunder standard decorators (regression guard).@dec+accessorcombined.Before-fix: tests fail with the
Expected ";"parse error. After-fix: 5 pass.Nearby decorator regression suites (
test/bundler/transpiler/es-decorators.test.ts,decorators.test.ts,decorator-metadata.test.ts,issue/27526.test.ts,issue/27575.test.ts) all still pass — 209 tests across those files, no regressions.Related (not closed by this PR)
@decorator accessor xparse error) — this PR fixes it under the default (standard-decorators) mode, but underexperimentalDecorators: trueit now raises a clear "can't mix" error instead of silently producing wrong decorator semantics. Fully supporting legacy@dec+accessorin the same class requires a separate lowering pass (desugaraccessorto#storage+ getter/setter before the legacy-decorator loop) — out of scope here.this.#fieldnot rewritten in class field initializers when class has@decorated accessor#28118 (this.#fieldnot rewritten in initializers under@decorated accessor) — unrelated private-field rewrite bug in the decorator-lowering path; still reproduces after this PR.