-
-
Notifications
You must be signed in to change notification settings - Fork 728
fix(parser): adjust class start position when decorators are involved #10438
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(parser): adjust class start position when decorators are involved #10438
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. |
CodSpeed Instrumentation Performance ReportMerging #10438 will not alter performanceComparing Summary
|
1b8b64d to
39540f7
Compare
Merge activity
|
39540f7 to
58ab8ff
Compare
…irst statement is `@dec export class C {}` (#10448)
#10438 aligned the spans of `@dec export class C {}` and `@dec export default class {}` with TS-ESLint.
```ts
@dec export class C {}
^^^^^^^^^^^^^^^^^ ExportNamedDeclaration
^^^^^^^^^^ Class
^^^^ Decorator
@dec export default class {}
^^^^^^^^^^^^^^^^^^^^^^^ ExportDefaultDeclaration
^^^^^^^^ Class
^^^^ Decorator
```
However, this causes a problem where one of these is the first statement in the file. In TS-ESTree, `Program` start is the start of the first token (excluding whitespace and comments). So we need to set `Program` start to the start of the decorator in these cases.
#10449) #10438 altered span of `Class` so it starts later in the case of `@dec export class C {}` and `@dec export default class {}`. Update `Utf8ToUtf16Converter` to handle this odd case, and visit decorators before the `export` keyword before processing the span start of `ExportNamedDeclaration` / `ExportDefaultDeclaration`, so that span offsets are still processed in ascending order.

closes #10409