Export classes defined wihtin internal modules correctelly

This commit is contained in:
Mohamed Hegazy 2015-03-16 21:18:31 -07:00
parent 99108694d5
commit 3d802438f1
3 changed files with 16 additions and 5 deletions

View file

@ -4929,6 +4929,18 @@ module ts {
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
writeLine();
emitMemberAssignments(node, NodeFlags.Static);
// If this is an exported classes, but not on the top level (i.e. on an internal
// module), export it
if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) {
writeLine();
emitStart(node);
emitModuleMemberName(node);
write(" = ");
emitDeclarationName(node);
emitEnd(node);
write(";");
}
}
function emitClassDeclarationBelowES6(node: ClassDeclaration) {
@ -4972,11 +4984,7 @@ module ts {
write(");");
emitEnd(node);
if (isES6ModuleMemberDeclaration(node)) {
// TODO update this to emit "export class " when ES67 class emit is available
emitES6NamedExportForDeclaration(node);
}
else if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) {
if (node.flags & NodeFlags.Export && !(node.flags & NodeFlags.Default)) {
writeLine();
emitStart(node);
emitModuleMemberName(node);

View file

@ -165,6 +165,7 @@ var m1;
}
c3.k = 20;
c3.l = 30;
m1.c3 = c3;
class c4 {
constructor() {
this.x = 10;
@ -205,6 +206,7 @@ var m2;
}
c3.k = 20;
c3.l = 30;
m2.c3 = c3;
class c4 {
constructor() {
this.x = 10;

View file

@ -27,4 +27,5 @@ var M;
set [Symbol.isRegExp](x) {
}
}
M.C = C;
})(M || (M = {}));