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): support override modifier for parameter property #3485

Merged
Show file tree
Hide file tree
Changes from 2 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
Expand Up @@ -12,6 +12,7 @@ export interface TSParameterProperty extends BaseNode {
readonly?: boolean;
static?: boolean;
export?: boolean;
override?: boolean;
parameter: AssignmentPattern | BindingName | RestElement;
decorators?: Decorator[];
}
@@ -0,0 +1,3 @@
class SpecializedComponent extends SomeComponent {
constructor(protected override readonly param: string) {}
}
@@ -0,0 +1,5 @@
class SpecializedComponent extends SomeComponent {
constructor(override param: string) {
super();
}
}
2 changes: 2 additions & 0 deletions packages/typescript-estree/src/convert.ts
Expand Up @@ -1585,6 +1585,8 @@ export class Converter {
hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined,
static: hasModifier(SyntaxKind.StaticKeyword, node) || undefined,
export: hasModifier(SyntaxKind.ExportKeyword, node) || undefined,
override:
hasModifier(SyntaxKind.OverrideKeyword, node) || undefined,
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
parameter: result,
});
}
Expand Down
Expand Up @@ -386,6 +386,12 @@ tester.addFixturePatternConfig('typescript/basics', {
* This is intentional; babel is not checking types
*/
'catch-clause-with-invalid-annotation',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* SyntaxError: Unexpected token, expected ","
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel/parser cannot parse override modifier for parameter properties, I'll report and fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
'class-with-constructor-and-parameter-property-with-modifiers',
'class-with-constructor-and-parameter-proptery-with-override-modifier',
],
ignoreSourceType: [
/**
Expand Down
Expand Up @@ -1746,6 +1746,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

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

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

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-with-constructor-and-parameter-proptery-with-override-modifier.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-with-constructor-and-return-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-with-constructor-and-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down