Skip to content

Commit

Permalink
Handle private access chained on an optional chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Rugvip committed Oct 4, 2020
1 parent 4c53842 commit a72e684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/traverser/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export function baseParseSubscript(
} else if (eat(tt.parenL)) {
parseCallExpressionArguments();
} else {
parseIdentifier();
parseMaybePrivateName();
}
} else if (eat(tt.dot)) {
state.tokens[state.tokens.length - 1].subscriptStartIndex = startTokenIndex;
Expand Down
7 changes: 7 additions & 0 deletions test/tokens-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ describe("tokens", () => {
#x = 3
}
this.#x = 3
delete this?.#x
if (#x in obj) { }
`,
[
Expand All @@ -345,6 +346,12 @@ describe("tokens", () => {
{type: tt.eq},
{type: tt.num},

{type: tt._delete},
{type: tt._this},
{type: tt.questionDot},
{type: tt.hash},
{type: tt.name},

{type: tt._if},
{type: tt.parenL},
{type: tt.hash},
Expand Down

0 comments on commit a72e684

Please sign in to comment.