From b2750ab73eb59eac54e7d03991cf593ae7efa206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 10 Aug 2020 15:04:29 -0400 Subject: [PATCH 1/2] chore: enable flowcheck on CI --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 75901f73511f..9b33cbcb2a83 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,7 @@ watch: build-no-bundle BABEL_ENV=development $(YARN) gulp watch code-quality-ci: build-no-bundle-ci - $(MAKE) flowcheck-ci & $(MAKE) lint-ci - + $(MAKE) flowcheck-ci lint-ci flowcheck-ci: $(MAKE) flow From 4fcf13e5c2300f1f3b115bc7426e6e35f3020d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Mon, 10 Aug 2020 15:17:43 -0400 Subject: [PATCH 2/2] fix: flow errors --- packages/babel-parser/src/parser/statement.js | 4 ++-- packages/babel-parser/src/plugins/estree.js | 1 - packages/babel-parser/src/plugins/placeholders.js | 3 ++- packages/babel-parser/src/plugins/typescript/index.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 28cd5d97fe39..ea5b295a9dab 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -639,7 +639,7 @@ export default class StatementParser extends ExpressionParser { return this.finishNode(node, "ThrowStatement"); } - parseCatchClauseParam(): N.Identifier { + parseCatchClauseParam(): N.Pattern { const param = this.parseBindingAtom(); const simple = param.type === "Identifier"; @@ -1199,7 +1199,7 @@ export default class StatementParser extends ExpressionParser { // https://tc39.es/ecma262/#prod-ClassBody parseClassBody( constructorAllowsSuper: boolean, - oldStrict?: boolean, + oldStrict: boolean, ): N.ClassBody { this.classScope.enter(); diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 06d79f3835dc..579f45e0b279 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -45,7 +45,6 @@ export default (superClass: Class): Class => estreeParseDecimalLiteral(value: any): N.Node { // https://github.com/estree/estree/blob/master/experimental/decimal.md - // $FlowIgnore // todo: use BigDecimal when node supports it. const decimal = null; const node = this.estreeParseLiteral(decimal); diff --git a/packages/babel-parser/src/plugins/placeholders.js b/packages/babel-parser/src/plugins/placeholders.js index 69d961e3e6c9..63b99a9b0308 100644 --- a/packages/babel-parser/src/plugins/placeholders.js +++ b/packages/babel-parser/src/plugins/placeholders.js @@ -203,6 +203,7 @@ export default (superClass: Class): Class => this.next(); this.takeDecorators(node); + const oldStrict = this.state.strict; const placeholder = this.parsePlaceholder("Identifier"); if (placeholder) { @@ -226,7 +227,7 @@ export default (superClass: Class): Class => this.parseClassSuper(node); node.body = this.parsePlaceholder("ClassBody") || - this.parseClassBody(!!node.superClass); + this.parseClassBody(!!node.superClass, oldStrict); return this.finishNode(node, type); } diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index 1b8c80eac6c5..f47149cd6079 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -2727,7 +2727,7 @@ export default (superClass: Class): Class => return hasContextParam ? baseCount + 1 : baseCount; } - parseCatchClauseParam(): N.Identifier { + parseCatchClauseParam(): N.Pattern { const param = super.parseCatchClauseParam(); const type = this.tsTryParseTypeAnnotation();