-
-
Notifications
You must be signed in to change notification settings - Fork 721
fix(transformer/legacy-decorator): metadata should be inserted after all params decorators #13215
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
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. |
There 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 order of decorators in the legacy decorator transformer to ensure metadata decorators are inserted after parameter decorators. The issue was that metadata decorators (specifically decorateMetadata) were being inserted before parameter decorators (decorateParam), which is incorrect according to the decorator specification.
- Reorders decorator insertion to place parameter decorators before metadata decorators
- Updates test fixtures to reflect the correct decorator ordering
- Improves test coverage by adding a new test case for parameter decorators
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_transformer/src/decorator/legacy/mod.rs | Core fix that splits and reorders decorators to ensure metadata comes after parameters |
| tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/params/input.ts | New test case with various parameter decorator scenarios |
| tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/params/output.js | Expected output for the new parameter decorator test |
| Multiple output.js/.ts files | Updated expected outputs reflecting the corrected decorator ordering |
| tasks/transform_conformance/snapshots/oxc.snap.md | Updated test results showing one additional passing test |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13215 will not alter performanceComparing Summary
Footnotes |
558425a to
10b9cc0
Compare
overlookmotel
left a comment
There 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.
My only question, which isn't actually relevant to this PR specifically, is why metadata decorators are added to method.decorators, only to be removed again.
The method of distinguishing "real" decorators from metadata decorators by whether they have an empty span works now because no other transform creates new unspanned "real" decorators. But it's not so future-proof.
- It couples this transform to all the other transforms via this assumption.
- Once we have transform plugins, user code might create new decorators with empty spans, and then this code would malfunction.
An alternative which I think could work: Transform hold a stack of Vecs, each representing "decorators to be added to current class". As it traverses through methods, props etc, it'd add transpiled decorators to that Vec. Then exit_class would add them all after the class.
Maybe that's also more efficient, as it doesn't require looping through all class elements again in exit_class. Maybe...
Merge activity
|
10b9cc0 to
76a9865
Compare
Thanks for reviewing this. I agree with your point, which is what I am trying to avoid, but it is troublesome in practice.
I'm not sure if I understand what you mean. Let me describe the transformation order here Currently, metadata decorators are inserted during the In your approach, I don't think the problem that metadata is being inserted before the real param decorators are inserted is solved. I had a thought that we could store metadata in a temporary To sum up, I am happy to make changes for this. The reason I use |
…cation of metadata (#13227) Fixes: #13215 (review) Collect metadata and store them in a `VecDeque`, and take them when transforming the class decorators in the `exit_class` side, which can eliminate the unreliable check of `span.is_unspanned` for metadata decorators. However, it introduces a little complexity.

Uh oh!
There was an error while loading. Please reload this page.