diff --git a/src/parser/statement.js b/src/parser/statement.js index 7687b93677..f6f92d6267 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -923,7 +923,9 @@ pp.checkExport = function (node, checkNames, isDefault) { this.checkDuplicateExports(node, node.declaration.id.name, isDefault); } else if (node.declaration.type === "VariableDeclaration") { for (let declaration of node.declaration.declarations) { - this.checkDuplicateExports(declaration, declaration.id.name, isDefault); + if (declaration.id.name) { + this.checkDuplicateExports(declaration, declaration.id.name, isDefault); + } } } } diff --git a/test/fixtures/es2015/modules/duplicate-named-export-destructuring/actual.js b/test/fixtures/es2015/modules/duplicate-named-export-destructuring/actual.js new file mode 100644 index 0000000000..9d1d9ff7ae --- /dev/null +++ b/test/fixtures/es2015/modules/duplicate-named-export-destructuring/actual.js @@ -0,0 +1,2 @@ +export const { rhythm } = typography; +export const { TypographyStyle } = typography; diff --git a/test/fixtures/es2015/modules/duplicate-named-export-destructuring/expected.json b/test/fixtures/es2015/modules/duplicate-named-export-destructuring/expected.json new file mode 100644 index 0000000000..690a0c4990 --- /dev/null +++ b/test/fixtures/es2015/modules/duplicate-named-export-destructuring/expected.json @@ -0,0 +1,312 @@ +{ + "type": "File", + "start": 0, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 46 + } + }, + "sourceType": "module", + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "ObjectPattern", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "rhythm" + }, + "name": "rhythm" + }, + "value": { + "type": "Identifier", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "rhythm" + }, + "name": "rhythm" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 26, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "typography" + }, + "name": "typography" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 38, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 46 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 45, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 46 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 51, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "id": { + "type": "ObjectPattern", + "start": 51, + "end": 70, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 53, + "end": 68, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "start": 53, + "end": 68, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "TypographyStyle" + }, + "name": "TypographyStyle" + }, + "value": { + "type": "Identifier", + "start": 53, + "end": 68, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "TypographyStyle" + }, + "name": "TypographyStyle" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 73, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 45 + }, + "identifierName": "typography" + }, + "name": "typography" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file