Skip to content

Commit

Permalink
fix flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jun 14, 2022
1 parent b17c0a3 commit 8835efd
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -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,
});
}
}
}
Expand Down

0 comments on commit 8835efd

Please sign in to comment.