Skip to content

Commit ef20ccb

Browse files
committed
Restore earlier behaviour when parsing non-simple arrow function bodies
1 parent 1f1071b commit ef20ccb

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/compiler/parser.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,14 +3040,11 @@ module ts {
30403040

30413041
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
30423042
// have an opening brace, just in case we're in an error state.
3043-
arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, false, Diagnostics._0_expected, "=>");
3044-
if (arrowFunction.equalsGreaterThanToken.kind === SyntaxKind.EqualsGreaterThanToken || token === SyntaxKind.OpenBraceToken) {
3045-
arrowFunction.body = parseArrowFunctionExpressionBody();
3046-
}
3047-
else {
3048-
// If not, we're probably better off bailing out and returning a bogus function expression.
3049-
arrowFunction.body = parseIdentifier();
3050-
}
3043+
var lastToken = token;
3044+
arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition:*/false, Diagnostics._0_expected, "=>");
3045+
arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken)
3046+
? parseArrowFunctionExpressionBody()
3047+
: parseIdentifier();
30513048

30523049
return finishNode(arrowFunction);
30533050
}

0 commit comments

Comments
 (0)