Skip to content

Implement TC39 Stage 3 decorators and auto-accessors (preliminary)#2368

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:compat-table
Mar 26, 2026
Merged

Implement TC39 Stage 3 decorators and auto-accessors (preliminary)#2368
lahma merged 1 commit into
sebastienros:mainfrom
lahma:compat-table

Conversation

@lahma

@lahma lahma commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Preliminary support for the TC39 Stage 3 decorators proposal. The decorators specification has not yet been formally approved into the ECMAScript standard — this implementation follows the Stage 3 proposal.

Auto-accessors (accessor keyword):

  • Public, private, and static auto-accessors with getter/setter pairs
  • Backed by per-instance private storage using PrivateName
  • Correct override and inheritance semantics

Decorator evaluation:

  • Method/getter/setter decorators: receive function value, can return replacement
  • Field decorators: receive undefined, can return initializer wrapper
  • Auto-accessor decorators: receive {get, set}, can return {get?, set?, init?}
  • Class decorators: receive constructor, can return replacement
  • addInitializer callback for both instance and static contexts
  • Correct application order (last decorator applied first)
  • Decorator context object with kind, name, static, private, addInitializer

Test plan

  • Full test262: 95,985 passed, 0 failures, no regressions
  • test262 decorator staging tests: 34/34 passed (public-auto-accessor, private-auto-accessor, accessor-as-identifier)
  • 20 new decorator unit tests covering: method/class/field/accessor decorators, addInitializer, multiple decorators, getter/setter decorators, static decorators, context properties

🤖 Generated with Claude Code

Add support for the TC39 Stage 3 decorators proposal:

Auto-accessors (accessor keyword):
- Public, private, and static auto-accessors with getter/setter pairs
- Backed by per-instance private storage using PrivateName
- Correct override and inheritance semantics

Decorator evaluation:
- Method/getter/setter decorators: receive function value, can return replacement
- Field decorators: receive undefined, can return initializer wrapper
- Auto-accessor decorators: receive {get, set}, can return {get?, set?, init?}
- Class decorators: receive constructor, can return replacement
- addInitializer callback for both instance and static contexts
- Correct application order (last decorator applied first)
- Decorator context with kind, name, static, private, addInitializer

Note: This is preliminary support - the decorators specification has not yet
been formally approved into the ECMAScript standard. The implementation follows
the TC39 Stage 3 proposal as of 2024.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lahma
lahma enabled auto-merge (squash) March 26, 2026 10:24
@lahma
lahma merged commit b7c1e9d into sebastienros:main Mar 26, 2026
7 of 8 checks passed
@lahma
lahma deleted the compat-table branch March 26, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant