From 244e4580e9b89e0c94549a3149f9b5b75a244d6f Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 26 Feb 2019 11:15:34 -0800 Subject: [PATCH] Remove always false param allowExpressionBody (#9591) --- packages/babel-parser/src/parser/expression.js | 5 ++--- packages/babel-parser/src/parser/statement.js | 4 ---- packages/babel-parser/src/plugins/flow.js | 6 ++---- packages/babel-parser/src/plugins/typescript.js | 6 ++---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index f2bcfb19d3..df72050b7f 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -881,7 +881,7 @@ export default class ExpressionParser extends LValParser { !this.canInsertSemicolon() ) { this.next(); - return this.parseFunction(node, undefined, false, true); + return this.parseFunction(node, undefined, true); } else if ( canBeArrow && id.name === "async" && @@ -1804,10 +1804,9 @@ export default class ExpressionParser extends LValParser { parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { // $FlowIgnore (node is not bodiless if we get here) - this.parseFunctionBody(node, allowExpressionBody); + this.parseFunctionBody(node); this.finishNode(node, type); } diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 0f55802ea0..2d98842c8b 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -548,7 +548,6 @@ export default class StatementParser extends ExpressionParser { return this.parseFunction( node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), - false, isAsync, ); } @@ -1013,7 +1012,6 @@ export default class StatementParser extends ExpressionParser { parseFunction( node: T, statement?: number = FUNC_NO_FLAGS, - allowExpressionBody?: boolean = false, isAsync?: boolean = false, ): T { const isStatement = statement & FUNC_STATEMENT; @@ -1074,7 +1072,6 @@ export default class StatementParser extends ExpressionParser { this.parseFunctionBodyAndFinish( node, isStatement ? "FunctionDeclaration" : "FunctionExpression", - allowExpressionBody, ); }); @@ -1753,7 +1750,6 @@ export default class StatementParser extends ExpressionParser { return this.parseFunction( expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, - false, isAsync, ); } else if (this.match(tt._class)) { diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index af151c317d..f76f043c4b 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -1557,10 +1557,8 @@ export default (superClass: Class): Class => parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { - // For arrow functions, `parseArrow` handles the return type itself. - if (!allowExpressionBody && this.match(tt.colon)) { + if (this.match(tt.colon)) { const typeNode = this.startNode(); [ @@ -1575,7 +1573,7 @@ export default (superClass: Class): Class => : null; } - super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); + super.parseFunctionBodyAndFinish(node, type); } // interfaces diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 7418fd7221..343975243a 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -1481,10 +1481,8 @@ export default (superClass: Class): Class => parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { - // For arrow functions, `parseArrow` handles the return type itself. - if (!allowExpressionBody && this.match(tt.colon)) { + if (this.match(tt.colon)) { node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon); } @@ -1499,7 +1497,7 @@ export default (superClass: Class): Class => return; } - super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); + super.parseFunctionBodyAndFinish(node, type); } parseSubscript(