Fix two bugs in ES decorator lowering:
1. `export default class` with decorators crashed because the code assumed
the first statement from lowerClass was always s_class, but standard
decorator lowering can produce prefix variable declarations.
2. `accessor field!: Type` (definite assignment assertion) failed to parse
because the `!` operator was only recognized for `kind == .normal`,
excluding `auto_accessor`.
Also fix DCE check panic on non-s_class statements in export default.
Co-Authored-By: Claude <noreply@anthropic.com>
Implement complete lowering of TC39 stage-3 standard decorators (the
non-legacy variant used when tsconfig has no `experimentalDecorators`).
Passes all 147 esbuild decorator tests plus 22 additional Bun-specific
decorator tests.
Features implemented:
- Method, getter, setter decorators (static and instance)
- Field decorators with initializer replacement and extra initializers
- Auto-accessor lowering (accessor keyword → WeakMap + getter/setter)
- Private member decorators (methods, fields, accessors via WeakMap/WeakSet)
- Class decorators (statement and expression positions)
- Class expression decorators with comma-expression lowering
- Decorator metadata (Symbol.metadata)
- Proper decorator evaluation order (source order per TC39 spec)
- Class binding semantics (inner vs outer class name bindings)
- Static block extraction with this-replacement
- Computed property key pre-evaluation
Runtime helpers added to src/runtime.js:
__decoratorStart, __decorateElement, __decoratorMetadata,
__runInitializers
Fixes#4122Fixes#20206Fixes#14529Fixes#6051
Co-Authored-By: Claude <noreply@anthropic.com>
Replace `catch bun.outOfMemory()`, which can accidentally catch
non-OOM-related errors, with either `bun.handleOom` or a manual `catch
|err| switch (err)`.
(For internal tracking: fixes STAB-1070)
---------
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
### What does this PR do?
Reduce stack space usage of parseSuffix
### How did you verify your code works?
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Splits up js_parser.zig into multiple files. Also changes visitExprInOut
to use function calls rather than switch
Not ready:
- [ ] P.zig is ~70,000 tokens, still needs to get smaller
- [x] ~~measure zig build time before & after (is it slower?)~~ no
significant impact
---------
Co-authored-by: pfgithub <6010774+pfgithub@users.noreply.github.com>