Skip to content

fix(typescript-estree): don't double add decorators to a parameter property's parameter #5582

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

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class A {
constructor(@d private x: number) {}
}
5 changes: 0 additions & 5 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1669,11 +1669,6 @@ export class Converter {
parameter.optional = true;
}

const decorators = getDecorators(node);
if (decorators) {
parameter.decorators = decorators.map(d => this.convertChild(d));
}

const modifiers = getModifiers(node);
if (modifiers) {
return this.createNode<TSESTree.TSParameterProperty>(node, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
*/
'export-default-class-decorator',
'export-named-class-decorator',
/**
* babel sets the range of the export node to the start of the parameter
* TSESTree sets it to the start of the decorator
*/
'class-parameter-property',
],
});
tester.addFixturePatternConfig('typescript/decorators/method-decorators', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/class-decorator-factory.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/class-parameter-property.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/export-default-class-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/export-named-class-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down
Loading