Skip to content

Commit

Permalink
fix(typescript-estree): support private optional property definition (#…
Browse files Browse the repository at this point in the history
…3997)

* fix(typescript-estree): support private optional property definition

* test: add more test
  • Loading branch information
sosukesuzuki committed Oct 14, 2021
1 parent 154ec9a commit 8605e08
Show file tree
Hide file tree
Showing 4 changed files with 699 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo {
#prop?: string;
#propExplicitWithValue?: string = '';
#propImplicitWithValue? = '';
}
3 changes: 2 additions & 1 deletion packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,8 @@ export class Converter {

if (
(node.name.kind === SyntaxKind.Identifier ||
node.name.kind === SyntaxKind.ComputedPropertyName) &&
node.name.kind === SyntaxKind.ComputedPropertyName ||
node.name.kind === SyntaxKind.PrivateIdentifier) &&
node.questionToken
) {
result.optional = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

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

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

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

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

0 comments on commit 8605e08

Please sign in to comment.