@@ -63,7 +63,7 @@ namespace ts {
6363 let enclosingDeclaration : Node ;
6464 let necessaryTypeReferences : Map < true > | undefined ;
6565 let lateMarkedStatements : LateVisibilityPaintedStatement [ ] | undefined ;
66- let lateStatementReplacementMap : Map < VisitResult < LateVisibilityPaintedStatement > > ;
66+ let lateStatementReplacementMap : Map < VisitResult < LateVisibilityPaintedStatement | ExportAssignment > > ;
6767 let suppressNewDiagnosticContexts : boolean ;
6868 let exportedModulesFromDeclarationEmit : Symbol [ ] | undefined ;
6969
@@ -701,12 +701,12 @@ namespace ts {
701701 }
702702 }
703703
704- function isExternalModuleIndicator ( result : LateVisibilityPaintedStatement ) {
704+ function isExternalModuleIndicator ( result : LateVisibilityPaintedStatement | ExportAssignment ) {
705705 // Exported top-level member indicates moduleness
706706 return isAnyImportOrReExport ( result ) || isExportAssignment ( result ) || hasModifier ( result , ModifierFlags . Export ) ;
707707 }
708708
709- function needsScopeMarker ( result : LateVisibilityPaintedStatement ) {
709+ function needsScopeMarker ( result : LateVisibilityPaintedStatement | ExportAssignment ) {
710710 return ! isAnyImportOrReExport ( result ) && ! isExportAssignment ( result ) && ! hasModifier ( result , ModifierFlags . Export ) && ! isAmbientModule ( result ) ;
711711 }
712712
@@ -1047,7 +1047,43 @@ namespace ts {
10471047 return createVariableStatement ( /*modifiers*/ undefined , createVariableDeclarationList ( [ varDecl ] ) ) ;
10481048 } ) ;
10491049 const namespaceDecl = createModuleDeclaration ( /*decorators*/ undefined , ensureModifiers ( input , isPrivate ) , input . name ! , createModuleBlock ( declarations ) , NodeFlags . Namespace ) ;
1050- return [ clean , namespaceDecl ] ;
1050+
1051+ if ( ! hasModifier ( clean , ModifierFlags . ExportDefault ) ) {
1052+ return [ clean , namespaceDecl ] ;
1053+ }
1054+
1055+ const modifiers = createModifiersFromModifierFlags ( ( getModifierFlags ( clean ) & ~ ModifierFlags . ExportDefault ) | ModifierFlags . Ambient ) ;
1056+ const cleanDeclaration = updateFunctionDeclaration (
1057+ clean ,
1058+ /*decorators*/ undefined ,
1059+ modifiers ,
1060+ /*asteriskToken*/ undefined ,
1061+ clean . name ,
1062+ clean . typeParameters ,
1063+ clean . parameters ,
1064+ clean . type ,
1065+ /*body*/ undefined
1066+ ) ;
1067+
1068+ const namespaceDeclaration = updateModuleDeclaration (
1069+ namespaceDecl ,
1070+ /*decorators*/ undefined ,
1071+ modifiers ,
1072+ namespaceDecl . name ,
1073+ namespaceDecl . body
1074+ ) ;
1075+
1076+ const exportDefaultDeclaration = createExportAssignment (
1077+ /*decorators*/ undefined ,
1078+ /*modifiers*/ undefined ,
1079+ /*isExportEquals*/ false ,
1080+ namespaceDecl . name
1081+ ) ;
1082+
1083+ resultHasExternalModuleIndicator = true ;
1084+ resultHasScopeMarker = true ;
1085+
1086+ return [ cleanDeclaration , namespaceDeclaration , exportDefaultDeclaration ] ;
10511087 }
10521088 else {
10531089 return clean ;
0 commit comments