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

refactor: add isLiteralPropertyName to parser utils #11547

Merged
merged 5 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: keyword is valid identifierName
  • Loading branch information
JLHwung committed May 12, 2020
commit 6686faab5e83ca3fce50d25e1285236b7bda43dc
4 changes: 1 addition & 3 deletions packages/babel-parser/src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,6 @@ export default class ExpressionParser extends LValParser {
prop.key.name === "async" &&
(this.isLiteralPropertyName() ||
this.match(tt.bracketL) ||
this.state.type.keyword ||
this.match(tt.star)) &&
!this.hasPrecedingLineBreak()
);
Expand Down Expand Up @@ -1645,8 +1644,7 @@ export default class ExpressionParser extends LValParser {
prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") &&
(this.isLiteralPropertyName() || // get foo() {}
this.match(tt.bracketL) || // get ["string"]() {}
!!this.state.type.keyword) // get debugger() {}
this.match(tt.bracketL)) // get ["string"]() {}
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/babel-parser/src/parser/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export default class UtilParser extends Tokenizer {
isLiteralPropertyName(): boolean {
return (
this.match(tt.name) ||
!!this.state.type.keyword ||
this.match(tt.string) ||
this.match(tt.num) ||
this.match(tt.bigint)
existentialism marked this conversation as resolved.
Show resolved Hide resolved
Expand Down