Skip to content

Commit f9a1fca

Browse files
ikatyangmhegazy
authored andcommitted
Add missing emitter for NamespaceExportDeclaration (#16025)
1 parent e4d6752 commit f9a1fca

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,7 @@ namespace ts {
33983398
case SyntaxKind.IndexedAccessType:
33993399
case SyntaxKind.MappedType:
34003400
case SyntaxKind.LiteralType:
3401+
case SyntaxKind.NamespaceExportDeclaration:
34013402
// Types and signatures are TypeScript syntax, and exclude all other facts.
34023403
transformFlags = TransformFlags.AssertTypeScript;
34033404
excludeFlags = TransformFlags.TypeExcludes;

src/compiler/emitter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ namespace ts {
571571
return emitModuleBlock(<ModuleBlock>node);
572572
case SyntaxKind.CaseBlock:
573573
return emitCaseBlock(<CaseBlock>node);
574+
case SyntaxKind.NamespaceExportDeclaration:
575+
return emitNamespaceExportDeclaration(<NamespaceExportDeclaration>node);
574576
case SyntaxKind.ImportEqualsDeclaration:
575577
return emitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
576578
case SyntaxKind.ImportDeclaration:
@@ -1886,6 +1888,12 @@ namespace ts {
18861888
write(";");
18871889
}
18881890

1891+
function emitNamespaceExportDeclaration(node: NamespaceExportDeclaration) {
1892+
write("export as namespace ");
1893+
emit(node.name);
1894+
write(";");
1895+
}
1896+
18891897
function emitNamedExports(node: NamedExports) {
18901898
emitNamedImportsOrExports(node);
18911899
}

src/compiler/transformers/ts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ namespace ts {
345345

346346
case SyntaxKind.PropertyDeclaration:
347347
// TypeScript property declarations are elided.
348+
349+
case SyntaxKind.NamespaceExportDeclaration:
350+
// TypeScript namespace export declarations are elided.
348351
return undefined;
349352

350353
case SyntaxKind.Constructor:

src/harness/unittests/printer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ namespace ts {
131131

132132
// tslint:enable boolean-trivia
133133
printsCorrectly("class", {}, printer => printer.printNode(EmitHint.Unspecified, syntheticNode, sourceFile));
134+
135+
printsCorrectly("namespaceExportDeclaration", {}, printer => printer.printNode(EmitHint.Unspecified, createNamespaceExportDeclaration("B"), sourceFile));
136+
134137
printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode(EmitHint.Unspecified, classWithOptionalMethodAndProperty, sourceFile));
135138
});
136139
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export as namespace B;

0 commit comments

Comments
 (0)