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
Tokenize keywords-like identifier as new tokens #13769
Tokenize keywords-like identifier as new tokens #13769
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6fdea76:
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/48823/ |
3bd0561
to
1ccd28b
Compare
lookahead.type === tt.string || | ||
lookahead.type === tt.num | ||
) { | ||
if (tokenIsLiteralPropertyName(lookahead.type)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug fix: Flow allows any identifiers to be the accessor type property. e.g.
type A = { get if(): number }
is a valid Flow code.
this.match(tt.name) && | ||
this.state.value === "interface" | ||
) { | ||
if (this.state.strict && this.isContextual(tt._interface)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5a1ca81
to
6fdea76
Compare
Ugh this title is going to mean nothing when it appears in the changelog under "Spec Compliance" 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
interf\u{61}ce A {}
whenflows
is enabled.This PR is based on #13768. The
tt.name
is now exploded into multiple tokens, each of them represents an "interested" identifier name (such asasync
,static
) which subjects to additional parsing logic. The tokens is not limited to ES, the Flow/TS keyword-likes are also tokenized differently for parsing convenience.The
isContextual
,expectContextual
now accept a token type instead of a string since these names are tokenized into different types. The verification is simplified because, e.g.token === tt._async
already implies thattoken
is an identifier token.