Also check AssignmentPatterns for export name (#9521)
This commit is contained in:
parent
d1fe2d05f4
commit
058f057426
@ -1816,7 +1816,9 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkDeclaration(node: N.Pattern | N.ObjectProperty): void {
|
checkDeclaration(node: N.Pattern | N.ObjectProperty): void {
|
||||||
if (node.type === "ObjectPattern") {
|
if (node.type === "Identifier") {
|
||||||
|
this.checkDuplicateExports(node, node.name);
|
||||||
|
} else if (node.type === "ObjectPattern") {
|
||||||
for (const prop of node.properties) {
|
for (const prop of node.properties) {
|
||||||
this.checkDeclaration(prop);
|
this.checkDeclaration(prop);
|
||||||
}
|
}
|
||||||
@ -1830,8 +1832,8 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.checkDeclaration(node.value);
|
this.checkDeclaration(node.value);
|
||||||
} else if (node.type === "RestElement") {
|
} else if (node.type === "RestElement") {
|
||||||
this.checkDeclaration(node.argument);
|
this.checkDeclaration(node.argument);
|
||||||
} else if (node.type === "Identifier") {
|
} else if (node.type === "AssignmentPattern") {
|
||||||
this.checkDuplicateExports(node, node.name);
|
this.checkDeclaration(node.left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
export { foo };
|
||||||
|
export const { foo = 1 } = bar;
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"sourceType": "module",
|
||||||
|
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user