Don't parse param init when = is required but missing

Makes another test case pass that was taking exponential time to parse,
because now it notices that the = is not present and doesn't even try to
parse the initialiser expression.
This commit is contained in:
Nathan Shively-Sanders
2017-09-14 13:05:03 -07:00
parent 3a25650f1d
commit 86d5311feb
5 changed files with 739 additions and 3 deletions
+2 -3
View File
@@ -3025,9 +3025,8 @@ namespace ts {
return undefined;
}
if (inParameter && requireEqualsToken) {
// this occurs with speculative parsing of lambdas, so try to consume the initializer,
// but signal that the parameter was missing the equals sign so it can abort if it wants
parseAssignmentExpressionOrHigher();
// = is required when speculatively parsing arrow function parameters,
// so return a fake initializer as a signal that the equals token was missing
const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier;
result.escapedText = "= not found" as __String;
return result;