[flow] Allow type casts in array patterns inside arrow parameters (#9069)

This commit is contained in:
Nicolò Ribaudo
2018-11-24 12:23:49 +01:00
committed by GitHub
parent d2971a1959
commit 856edbf95f
15 changed files with 1801 additions and 6 deletions

View File

@@ -1977,7 +1977,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// type casts that we've found that are illegal in this context
toReferencedList(
exprList: $ReadOnlyArray<?N.Expression>,
isInParens?: boolean,
isParenthesizedExpr?: boolean,
): $ReadOnlyArray<?N.Expression> {
for (let i = 0; i < exprList.length; i++) {
const expr = exprList[i];
@@ -1985,7 +1985,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
expr &&
expr.type === "TypeCastExpression" &&
(!expr.extra || !expr.extra.parenthesized) &&
(exprList.length > 1 || !isInParens)
(exprList.length > 1 || !isParenthesizedExpr)
) {
this.raise(
expr.typeAnnotation.start,