exclude 'default' from star exports

This commit is contained in:
Vladimir Matveev 2015-04-29 11:43:23 -07:00
parent 5f18d9b912
commit 4a919d4f04
5 changed files with 24 additions and 13 deletions

View file

@ -5047,11 +5047,11 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
writeLine();
write(` for(var n in m) {`);
writeLine();
write(` `);
write(` if (n !== "default"`);
if (localNames) {
write(`if (!${localNames}.hasOwnProperty(n)) `);
write(`&& !${localNames}.hasOwnProperty(n)`);
}
write(`${exportFunctionForFile}(n, m[n]);`);
write(`) ${exportFunctionForFile}(n, m[n]);`);
writeLine();
write(" }");
writeLine();
@ -5061,6 +5061,10 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
}
function writeExportedName(node: Identifier | Declaration): void {
if (node.kind !== SyntaxKind.Identifier && node.flags & NodeFlags.Default) {
return;
}
if (started) {
write(",");
}
@ -5073,9 +5077,6 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
if (node.kind === SyntaxKind.Identifier) {
emitNodeWithoutSourceMap(node);
}
else if (node.flags & NodeFlags.Default) {
write("default");
}
else {
emitDeclarationName(<Declaration>node);
}

View file

@ -1,8 +1,8 @@
tests/cases/compiler/file1.ts(7,15): error TS2307: Cannot find module 'bar'.
tests/cases/compiler/file2.ts(7,15): error TS2307: Cannot find module 'bar'.
tests/cases/compiler/file3.ts(2,25): error TS2307: Cannot find module 'a'.
tests/cases/compiler/file3.ts(3,15): error TS2307: Cannot find module 'bar'.
tests/cases/compiler/file4.ts(8,27): error TS2307: Cannot find module 'a'.
tests/cases/compiler/file3.ts(4,15): error TS2307: Cannot find module 'bar'.
tests/cases/compiler/file4.ts(9,27): error TS2307: Cannot find module 'a'.
tests/cases/compiler/file5.ts(3,15): error TS2307: Cannot find module 'a'.
@ -33,6 +33,7 @@ tests/cases/compiler/file5.ts(3,15): error TS2307: Cannot find module 'a'.
export {x, y as z} from 'a';
~~~
!!! error TS2307: Cannot find module 'a'.
export default function foo() {}
export * from 'bar';
~~~~~
!!! error TS2307: Cannot find module 'bar'.
@ -41,6 +42,7 @@ tests/cases/compiler/file5.ts(3,15): error TS2307: Cannot find module 'a'.
export var x;
export function foo() {}
export default function (){}
var z, z1;
export {z, z1 as z2};

View file

@ -21,12 +21,14 @@ export * from 'bar';
//// [file3.ts]
export {x, y as z} from 'a';
export default function foo() {}
export * from 'bar';
//// [file4.ts]
export var x;
export function foo() {}
export default function (){}
var z, z1;
export {z, z1 as z2};
@ -50,7 +52,7 @@ System.register(['bar'], function(exports_1) {
};
function exportStar_1(m) {
for(var n in m) {
if (!exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
}
}
return {
@ -72,7 +74,7 @@ System.register(['bar'], function(exports_1) {
};
function exportStar_1(m) {
for(var n in m) {
if (!exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
}
}
return {
@ -88,13 +90,15 @@ System.register(['bar'], function(exports_1) {
});
//// [file3.js]
System.register(['a', 'bar'], function(exports_1) {
function foo() { }
exports_1("default", foo);
var exportedNames_1 = {
'x': true,
'z': true
};
function exportStar_1(m) {
for(var n in m) {
if (!exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
}
}
return {
@ -115,6 +119,8 @@ System.register(['a'], function(exports_1) {
var x, z, z1;
function foo() { }
exports_1("foo", foo);
function default_1() { }
exports_1("default", default_1);
return {
setters:[
function (_a_1) {
@ -133,7 +139,7 @@ System.register(['a'], function(exports_1) {
function foo() { }
function exportStar_1(m) {
for(var n in m) {
exports_1(n, m[n]);
if (n !== "default") exports_1(n, m[n]);
}
}
return {

View file

@ -31,7 +31,7 @@ System.register(['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7'],
};
function exportStar_1(m) {
for(var n in m) {
if (!exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports_1(n, m[n]);
}
}
return {

View file

@ -21,12 +21,14 @@ export * from 'bar';
// @filename: file3.ts
export {x, y as z} from 'a';
export default function foo() {}
export * from 'bar';
// @filename: file4.ts
export var x;
export function foo() {}
export default function (){}
var z, z1;
export {z, z1 as z2};