Handel export name bindings in internal modules in ES6

This commit is contained in:
Mohamed Hegazy
2015-03-16 21:58:57 -07:00
parent 3d802438f1
commit 1932f720cb
7 changed files with 380 additions and 2 deletions
+19 -2
View File
@@ -4930,7 +4930,7 @@ module ts {
writeLine();
emitMemberAssignments(node, NodeFlags.Static);
// If this is an exported classes, but not on the top level (i.e. on an internal
// If this is an exported class, but not on the top level (i.e. on an internal
// module), export it
if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) {
writeLine();
@@ -5348,7 +5348,7 @@ module ts {
}
function emitExportDeclaration(node: ExportDeclaration) {
if (languageVersion < ScriptTarget.ES6) {
if (languageVersion < ScriptTarget.ES6 || node.parent.kind !== SyntaxKind.SourceFile) {
if (node.moduleSpecifier) {
emitStart(node);
let generatedName = resolver.getGeneratedNameForNode(node);
@@ -5386,6 +5386,23 @@ module ts {
}
emitEnd(node);
}
else {
// internal module
if (node.exportClause) {
// export { x, y, ... }
forEach(node.exportClause.elements, specifier => {
writeLine();
emitStart(specifier);
emitContainingModuleName(specifier);
write(".");
emitNodeWithoutSourceMap(specifier.name);
write(" = ");
emitNodeWithoutSourceMap(specifier.propertyName || specifier.name);
write(";");
emitEnd(specifier);
});
}
}
}
else {
write("export ");