Skip to content
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(typescript-estree): don't double add decorators to a parameter property's parameter #5582

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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