Also check AssignmentPatterns for export name (#9521)

This commit is contained in:
Daniel Tschinder 2019-02-15 22:55:03 -08:00 committed by GitHub
parent d1fe2d05f4
commit 058f057426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -1816,7 +1816,9 @@ export default class StatementParser extends ExpressionParser {
}
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) {
this.checkDeclaration(prop);
}
@ -1830,8 +1832,8 @@ export default class StatementParser extends ExpressionParser {
this.checkDeclaration(node.value);
} else if (node.type === "RestElement") {
this.checkDeclaration(node.argument);
} else if (node.type === "Identifier") {
this.checkDuplicateExports(node, node.name);
} else if (node.type === "AssignmentPattern") {
this.checkDeclaration(node.left);
}
}

View File

@ -0,0 +1,2 @@
export { foo };
export const { foo = 1 } = bar;

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)"
}