Correctly parse TS TypeAssertions around arrow functions (#9699)

This commit is contained in:
Daniel Tschinder
2019-03-18 22:18:47 -07:00
committed by GitHub
parent c285d5409e
commit 48d66eb648
6 changed files with 433 additions and 1 deletions

View File

@@ -2121,7 +2121,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`.
typeParameters = this.tsParseTypeParameters();
arrowExpression = super.parseMaybeAssign(...args);
if (arrowExpression.type !== "ArrowFunctionExpression") {
if (
arrowExpression.type !== "ArrowFunctionExpression" ||
(arrowExpression.extra && arrowExpression.extra.parenthesized)
) {
this.unexpected(); // Go to the catch block (needs a SyntaxError).
}
} catch (err) {