mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Improve parsing in await and yield context (#44680)
* Improve parsing in await and yield context
* Avoid yield and await check in identifier
* Revert "Avoid yield and awaitt check in identifier"
This reverts commit 9644859f29.
* Add some comments
This commit is contained in:
@@ -1501,6 +1501,8 @@ namespace ts {
|
||||
if (token() === SyntaxKind.Identifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder.
|
||||
return token() > SyntaxKind.LastReservedWord;
|
||||
}
|
||||
|
||||
@@ -6122,15 +6124,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function nextTokenIsIdentifierOrStartOfDestructuring() {
|
||||
function nextTokenIsBindingIdentifierOrStartOfDestructuring() {
|
||||
nextToken();
|
||||
return isIdentifier() || token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken;
|
||||
return isBindingIdentifier() || token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken;
|
||||
}
|
||||
|
||||
function isLetDeclaration() {
|
||||
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
||||
// or [.
|
||||
return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
|
||||
return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuring);
|
||||
}
|
||||
|
||||
function parseStatement(): Statement {
|
||||
|
||||
Reference in New Issue
Block a user