Add comments, change error message

This commit is contained in:
Wesley Wigham
2015-11-23 17:02:01 -08:00
parent 3b6fa314da
commit f782c82ba3
4 changed files with 18 additions and 14 deletions
+9 -5
View File
@@ -1093,12 +1093,16 @@ namespace ts {
return links.resolvedExports || (links.resolvedExports = getExportsForModule(moduleSymbol));
}
interface ExportedSymbolDiagnostics {
interface ExportCollisionTracker {
specifierText: string;
exportsWithDuplicate: ExportDeclaration[];
}
function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map<ExportedSymbolDiagnostics>, exportNode?: ExportDeclaration) {
/**
* Extends one symbol table with abother while collecting information on name collisions for error message generation into the `lookupTable` argument
* Not passing `lookupTable` and `exportNode` disables this collection, and just extends the tables
*/
function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map<ExportCollisionTracker>, exportNode?: ExportDeclaration) {
for (const id in source) {
if (id !== "default" && !hasProperty(target, id)) {
target[id] = source[id];
@@ -1129,7 +1133,7 @@ namespace ts {
const exportStars = symbol.exports["__export"];
if (exportStars) {
const nestedSymbols: SymbolTable = {};
const lookupTable: Map<ExportedSymbolDiagnostics> = {};
const lookupTable: Map<ExportCollisionTracker> = {};
for (const node of exportStars.declarations) {
const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier);
const exportedSymbols = visit(resolvedModule);
@@ -1149,7 +1153,7 @@ namespace ts {
for (const node of exportsWithDuplicate) {
diagnostics.add(createDiagnosticForNode(
node,
Diagnostics.An_export_Asterisk_from_0_declaration_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity,
Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity,
lookupTable[id].specifierText,
id
));
@@ -14094,7 +14098,7 @@ namespace ts {
}
function isNotOverload(declaration: Declaration): boolean {
return (declaration.kind !== SyntaxKind.FunctionDeclaration || typeof (declaration as FunctionDeclaration).body !== "undefined");
return declaration.kind !== SyntaxKind.FunctionDeclaration || !!(declaration as FunctionDeclaration).body;
}
}
+1 -1
View File
@@ -836,7 +836,7 @@
"category": "Error",
"code": 2307
},
"An `export * from {0}` declaration has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.": {
"Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.": {
"category": "Error",
"code": 2308
},
@@ -1,6 +1,6 @@
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from "./t1"` declaration has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from "./t1"` declaration has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
@@ -23,9 +23,9 @@ tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from
export * from "./t2";
export * from "./t3";
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2308: An `export * from "./t1"` declaration has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2308: An `export * from "./t1"` declaration has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
import hello, { x, y, z, foo } from "./t4";
@@ -1,6 +1,6 @@
tests/cases/conformance/es6/modules/main.ts(1,8): error TS1192: Module '"tests/cases/conformance/es6/modules/t4"' has no default export.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from "./t1"` declaration has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from "./t1"` declaration has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
@@ -23,9 +23,9 @@ tests/cases/conformance/es6/modules/t4.ts(3,1): error TS2308: An `export * from
export * from "./t2";
export * from "./t3";
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2308: An `export * from "./t1"` declaration has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
!!! error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2308: An `export * from "./t1"` declaration has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
!!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity.
==== tests/cases/conformance/es6/modules/main.ts (1 errors) ====
import hello, { x, y, z, foo } from "./t4";