Don't do the duplicate check if not an identifier (#140)

This commit is contained in:
Henry Zhu 2016-09-23 00:44:13 -04:00 committed by GitHub
parent 101e9e5636
commit 1d04d12794
3 changed files with 317 additions and 1 deletions

View File

@ -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);
}
}
}
}

View File

@ -0,0 +1,2 @@
export const { rhythm } = typography;
export const { TypographyStyle } = typography;

View File

@ -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": []
}
}