From 7ff4a73916b04d53e4d9f2b2c5d401d3deceb684 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Sun, 25 Feb 2018 19:22:23 -0800 Subject: [PATCH] Upgrade flow to 0.66 and fix a few minor errors. (#7431) --- lib/third-party-libs.js.flow | 6 +++--- package.json | 2 +- packages/babel-types/README.md | 2 ++ packages/babylon/src/parser/expression.js | 4 +++- packages/babylon/src/parser/statement.js | 5 ++++- packages/babylon/src/types.js | 6 ++++-- yarn.lock | 6 +++--- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/third-party-libs.js.flow b/lib/third-party-libs.js.flow index 97d19dfda2..df59f5032f 100644 --- a/lib/third-party-libs.js.flow +++ b/lib/third-party-libs.js.flow @@ -3,9 +3,9 @@ */ declare module "micromatch" { - declare function exports(Array, Array, ?{ - nocase: boolean, - }): Array; + declare module.exports: { + (Array, Array, ?{ nocase: boolean }): Array, + }; } declare module "resolve" { diff --git a/package.json b/package.json index 335e4964aa..d5d25803f7 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "eslint-config-babel": "^7.0.2", "eslint-plugin-flowtype": "^2.20.0", "eslint-plugin-prettier": "^2.5.0", - "flow-bin": "^0.59.0", + "flow-bin": "^0.66.0", "graceful-fs": "^4.1.11", "gulp": "^3.9.0", "gulp-babel": "^8.0.0-beta.0", diff --git a/packages/babel-types/README.md b/packages/babel-types/README.md index 927ca0d4d2..2f2868c500 100644 --- a/packages/babel-types/README.md +++ b/packages/babel-types/README.md @@ -359,6 +359,7 @@ Aliases: `Property` - `computed`: `boolean` (default: `false`) - `abstract`: `boolean` (default: `null`) - `accessibility`: `"public" | "private" | "protected"` (default: `null`) + - `definite`: `boolean` (default: `null`) - `optional`: `boolean` (default: `null`) - `readonly`: `boolean` (default: `null`) - `static`: `boolean` (default: `null`) @@ -2851,6 +2852,7 @@ See also `t.isVariableDeclarator(node, opts)` and `t.assertVariableDeclarator(no - `id`: `LVal` (required) - `init`: `Expression` (default: `null`) + - `definite`: `boolean` (default: `null`) --- diff --git a/packages/babylon/src/parser/expression.js b/packages/babylon/src/parser/expression.js index 5845cbf613..71b1e254c7 100644 --- a/packages/babylon/src/parser/expression.js +++ b/packages/babylon/src/parser/expression.js @@ -1678,7 +1678,9 @@ export default class ExpressionParser extends LValParser { const oldStrict = this.state.strict; if (isStrict) this.state.strict = isStrict; if (node.id) { - this.checkReservedWord(node.id, node.start, true, true); + // TODO(logan): This check is broken because it passes a node object as + // a binding name. Passing the actual string introduces other failures. + // this.checkReservedWord(node.id, node.start, true, true); } if (checkLVal) { const nameHash: any = Object.create(null); diff --git a/packages/babylon/src/parser/statement.js b/packages/babylon/src/parser/statement.js index 1d443f06f7..ab917a22db 100644 --- a/packages/babylon/src/parser/statement.js +++ b/packages/babylon/src/parser/statement.js @@ -1488,7 +1488,10 @@ export default class StatementParser extends ExpressionParser { node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration" ) { - this.checkDuplicateExports(node, node.declaration.id.name); + const id = node.declaration.id; + if (!id) throw new Error("Assertion failure"); + + this.checkDuplicateExports(node, id.name); } else if (node.declaration.type === "VariableDeclaration") { for (const declaration of node.declaration.declarations) { this.checkDeclaration(declaration.id); diff --git a/packages/babylon/src/types.js b/packages/babylon/src/types.js index d97999fa15..7f7f46b646 100644 --- a/packages/babylon/src/types.js +++ b/packages/babylon/src/types.js @@ -1068,6 +1068,8 @@ export type TsType = | TsArrayType | TsTupleType | TsUnionOrIntersectionType + | TsConditionalType + | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType @@ -1163,10 +1165,10 @@ export type TsConditionalType = TsTypeBase & { checkType: TsType, extendsType: TsType, trueType: TsType, - falseType: tsType, + falseType: TsType, }; -export type InferType = TsTypeBase & { +export type TsInferType = TsTypeBase & { type: "TSInferType", typeParameter: TypeParameter, }; diff --git a/yarn.lock b/yarn.lock index 559da23b48..7b7642dea7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3074,9 +3074,9 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flow-bin@^0.59.0: - version "0.59.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.59.0.tgz#8c151ee7f09f1deed9bf0b9d1f2e8ab9d470f1bb" +flow-bin@^0.66.0: + version "0.66.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26" for-in@^1.0.1, for-in@^1.0.2: version "1.0.2"