mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
correctly parse destructuring in let outside of strict mode
This commit is contained in:
@@ -2975,6 +2975,11 @@ module ts {
|
||||
return !scanner.hasPrecedingLineBreak() && isIdentifier()
|
||||
}
|
||||
|
||||
function netTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.OpenBracketToken)
|
||||
}
|
||||
|
||||
function parseYieldExpression(): YieldExpression {
|
||||
var node = <YieldExpression>createNode(SyntaxKind.YieldExpression);
|
||||
|
||||
@@ -4873,9 +4878,9 @@ module ts {
|
||||
}
|
||||
|
||||
function isLetDeclaration() {
|
||||
// It is let declaration if in strict mode or next token is identifier on same line.
|
||||
// It is let declaration if in strict mode or next token is identifier\open brace\open curly on same line.
|
||||
// otherwise it needs to be treated like identifier
|
||||
return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine);
|
||||
return inStrictModeContext() || lookAhead(netTokenIsIdentifierOrStartOfDestructuringOnTheSameLine);
|
||||
}
|
||||
|
||||
function isDeclarationStart(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user