diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index eb43f774605..f996af5f5e4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3046,14 +3046,11 @@ module ts { // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. - arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>"); - if (arrowFunction.equalsGreaterThanToken.kind === SyntaxKind.EqualsGreaterThanToken || token === SyntaxKind.OpenBraceToken) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - // If not, we're probably better off bailing out and returning a bogus function expression. - arrowFunction.body = parseIdentifier(); - } + var lastToken = token; + arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition:*/false, Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) + ? parseArrowFunctionExpressionBody() + : parseIdentifier(); return finishNode(arrowFunction); }