[TS] Disallow type casts in arrow parameters (#9612)

This commit is contained in:
Nicolò Ribaudo
2019-02-28 23:58:27 +01:00
committed by GitHub
parent d72f3aa758
commit f13f4adcbb
9 changed files with 28 additions and 2 deletions

View File

@@ -2268,8 +2268,18 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): $ReadOnlyArray<N.Pattern> {
for (let i = 0; i < exprList.length; i++) {
const expr = exprList[i];
if (expr && expr.type === "TSTypeCastExpression") {
exprList[i] = this.typeCastToParameter(expr);
if (!expr) continue;
switch (expr.type) {
case "TSTypeCastExpression":
exprList[i] = this.typeCastToParameter(expr);
break;
case "TSAsExpression":
case "TSTypeAssertion":
this.raise(
expr.start,
"Unexpected type cast in parameter position.",
);
break;
}
}
return super.toAssignableList(exprList, isBinding, contextDescription);