mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00: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:
1 parent
9708022537
commit
fafe3ff0b4
6 files changed
+388
-3
No files matched your search
@@ -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