diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8d3eacc3dfe..b4995a103f4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2989,11 +2989,14 @@ namespace ts { } function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction { - const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === Tristate.True) { - const asyncModifier = parseModifiersForArrowFunction(); - const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - return parseSimpleArrowFunctionExpression(expr, asyncModifier); + // We do a check here so that we won't be doing unnecessarily call to "lookAhead" + if (token === SyntaxKind.AsyncKeyword) { + const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); + if (isUnParenthesizedAsyncArrowFunction === Tristate.True) { + const asyncModifier = parseModifiersForArrowFunction(); + const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); + return parseSimpleArrowFunctionExpression(expr, asyncModifier); + } } return undefined; }