Skip to content

Commit

Permalink
fix(typescript-estree): don't double add decorators to a parameter pr…
Browse files Browse the repository at this point in the history
…operty's parameter (#5582)

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

* fix test
  • Loading branch information
bradzacher committed Sep 1, 2022
1 parent 946a510 commit 863694c
Show file tree
Hide file tree
Showing 5 changed files with 553 additions and 5 deletions.
@@ -0,0 +1,3 @@
class A {
constructor(@d private x: number) {}
}
5 changes: 0 additions & 5 deletions packages/typescript-estree/src/convert.ts
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
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
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

0 comments on commit 863694c

Please sign in to comment.