-
-
Notifications
You must be signed in to change notification settings - Fork 710
fix(transformer/legacy-decorator): correct generating metadata for getter/setter methods #14495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(transformer/legacy-decorator): correct generating metadata for getter/setter methods #14495
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
design:returntype metadata for getter/setter methods
CodSpeed Performance ReportMerging #14495 will not alter performanceComparing Summary
Footnotes
|
82bc0f9 to
81cc96a
Compare
design:returntype metadata for getter/setter methodsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the TypeScript decorator metadata generation for getter and setter methods to match TypeScript's emitDecoratorMetadata behavior. Getter and setter methods should not include design:returntype metadata, only design:type and design:paramtypes.
- Fixed metadata generation to exclude
design:returntypefor getter/setter methods - Updated the method metadata stack to use optional expressions to handle varying metadata counts
- Added test coverage for getter/setter method metadata behavior
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_transformer/src/decorator/legacy/metadata.rs |
Modified metadata generation logic to conditionally include return type metadata and updated data structures to support optional expressions |
crates/oxc_transformer/src/decorator/legacy/mod.rs |
Updated metadata processing to handle optional expressions with flattening |
tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/getter-setter-method/input.ts |
Added test input with decorated getter, setter, and regular method |
tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/getter-setter-method/output.js |
Expected output showing correct metadata generation (no returntype for getter/setter) |
tasks/transform_conformance/snapshots/oxc.snap.md |
Updated test results to reflect the new passing test |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...onformance/tests/legacy-decorators/test/fixtures/oxc/metadata/getter-setter-method/output.js
Outdated
Show resolved
Hide resolved
...onformance/tests/legacy-decorators/test/fixtures/oxc/metadata/getter-setter-method/output.js
Outdated
Show resolved
Hide resolved
7ac6dc8 to
5ca03ef
Compare
45a037c to
eae13e6
Compare
Merge activity
|
…tter/setter methods (#14495) * Fixes: #14493 Getter and setter methods should not have `design:returntype` metadata according to TypeScript's `emitDecoratorMetadata` behavior. They should only have `design:type` and `design:paramtypes`. **And `design:type` is different for the getter and setter:** Getter: `design:type` is the same as the return type of method. Setter: `design:type` is the same as the type of the first parameter of the method
eae13e6 to
2bc1978
Compare

Getter and setter methods should not have
design:returntypemetadata according to TypeScript'semitDecoratorMetadatabehavior. They should only havedesign:typeanddesign:paramtypes.And
design:typeis different for the getter and setter:Getter:
design:typeis the same as the return type of method.Setter:
design:typeis the same as the type of the first parameter of the method