From 8835efd20bb116a99fc24f733418d12c4ace4527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 14 Jun 2022 13:59:04 -0400 Subject: [PATCH] fix flow error --- packages/babel-parser/src/parser/statement.js | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index eb113b722c3d..f8c794af6878 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -2425,29 +2425,25 @@ export default class StatementParser extends ExpressionParser { | N.ExportNamedDeclaration | N.ImportDeclaration, ) { - if (this.isJSONModuleImport(node)) { + if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") { const { specifiers } = node; - if (specifiers == null) { - // ExportAllDeclaration - } else { - const nonDefaultNamedSpecifier = specifiers.find(specifier => { - let imported; - if (specifier.type === "ExportSpecifier") { - imported = specifier.local; - } else if (specifier.type === "ImportSpecifier") { - imported = specifier.imported; - } - if (imported !== undefined) { - return imported.type === "Identifier" - ? imported.name !== "default" - : imported.value !== "default"; - } - }); - if (nonDefaultNamedSpecifier !== undefined) { - this.raise(Errors.ImportJSONBindingNotDefault, { - at: nonDefaultNamedSpecifier.loc.start, - }); + const nonDefaultNamedSpecifier = specifiers.find(specifier => { + let imported; + if (specifier.type === "ExportSpecifier") { + imported = specifier.local; + } else if (specifier.type === "ImportSpecifier") { + imported = specifier.imported; + } + if (imported !== undefined) { + return imported.type === "Identifier" + ? imported.name !== "default" + : imported.value !== "default"; } + }); + if (nonDefaultNamedSpecifier !== undefined) { + this.raise(Errors.ImportJSONBindingNotDefault, { + at: nonDefaultNamedSpecifier.loc.start, + }); } } }