@@ -148,8 +148,8 @@ namespace ts {
148148 moduleElementDeclarationEmitInfo = [ ] ;
149149 }
150150
151- if ( ! isBundledEmit && isExternalModule ( sourceFile ) && sourceFile . moduleAugmentations . length && ! resultHasExternalModuleIndicator ) {
152- // if file was external module with augmentations - this fact should be preserved in .d.ts as well.
151+ if ( ! isBundledEmit && isExternalModule ( sourceFile ) && ! resultHasExternalModuleIndicator ) {
152+ // if file was external module this fact should be preserved in .d.ts as well.
153153 // in case if we didn't write any external module specifiers in .d.ts we need to emit something
154154 // that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here.
155155 write ( "export {};" ) ;
@@ -651,6 +651,9 @@ namespace ts {
651651 }
652652
653653 function emitExportAssignment ( node : ExportAssignment ) {
654+ if ( isSourceFile ( node . parent ) ) {
655+ resultHasExternalModuleIndicator = true ; // Top-level exports are external module indicators
656+ }
654657 if ( node . expression . kind === SyntaxKind . Identifier ) {
655658 write ( node . isExportEquals ? "export = " : "export default " ) ;
656659 writeTextOfNode ( currentText , node . expression ) ;
@@ -745,6 +748,7 @@ namespace ts {
745748 const modifiers = getModifierFlags ( node ) ;
746749 // If the node is exported
747750 if ( modifiers & ModifierFlags . Export ) {
751+ resultHasExternalModuleIndicator = true ; // Top-level exports are external module indicators
748752 write ( "export " ) ;
749753 }
750754
@@ -901,6 +905,7 @@ namespace ts {
901905 }
902906
903907 function emitExportDeclaration ( node : ExportDeclaration ) {
908+ resultHasExternalModuleIndicator = true ; // Top-level exports are external module indicators
904909 emitJsDocComments ( node ) ;
905910 write ( "export " ) ;
906911 if ( node . exportClause ) {
0 commit comments