Make exportIdentifiers and array so that base object properties are not accounted (#137)
This commit is contained in:
parent
3210bbbce0
commit
952d50faf9
@ -939,10 +939,10 @@ pp.checkExport = function (node, checkNames, isDefault) {
|
||||
};
|
||||
|
||||
pp.checkDuplicateExports = function(node, name, isDefault) {
|
||||
if (this.state.exportedIdentifiers[name]) {
|
||||
if (this.state.exportedIdentifiers.indexOf(name) > -1) {
|
||||
this.raiseDuplicateExportError(node, name, isDefault);
|
||||
}
|
||||
this.state.exportedIdentifiers[name] = true;
|
||||
this.state.exportedIdentifiers.push(name);
|
||||
};
|
||||
|
||||
pp.raiseDuplicateExportError = function(node, name, isDefault) {
|
||||
|
||||
@ -43,7 +43,7 @@ export default class State {
|
||||
this.containsEsc = this.containsOctal = false;
|
||||
this.octalPosition = null;
|
||||
|
||||
this.exportedIdentifiers = {};
|
||||
this.exportedIdentifiers = [];
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -123,7 +123,7 @@ export default class State {
|
||||
|
||||
// Names of exports store. `default` is stored as a name for both
|
||||
// `export default foo;` and `export { foo as default };`.
|
||||
exportedIdentifiers: {[id:string]: boolean};
|
||||
exportedIdentifiers: Array<string>;
|
||||
|
||||
curPosition() {
|
||||
return new Position(this.curLine, this.pos - this.lineStart);
|
||||
|
||||
1
test/fixtures/es2015/modules/duplicate-named-export-builtin/actual.js
vendored
Normal file
1
test/fixtures/es2015/modules/duplicate-named-export-builtin/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { toString };
|
||||
102
test/fixtures/es2015/modules/duplicate-named-export-builtin/expected.json
vendored
Normal file
102
test/fixtures/es2015/modules/duplicate-named-export-builtin/expected.json
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"declaration": null,
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start": 9,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 9,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "toString"
|
||||
},
|
||||
"name": "toString"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start": 9,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "toString"
|
||||
},
|
||||
"name": "toString"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user