@@ -63,7 +63,7 @@ namespace ts {
63
63
let enclosingDeclaration : Node ;
64
64
let necessaryTypeReferences : Map < true > | undefined ;
65
65
let lateMarkedStatements : LateVisibilityPaintedStatement [ ] | undefined ;
66
- let lateStatementReplacementMap : Map < VisitResult < LateVisibilityPaintedStatement > > ;
66
+ let lateStatementReplacementMap : Map < VisitResult < LateVisibilityPaintedStatement | ExportAssignment > > ;
67
67
let suppressNewDiagnosticContexts : boolean ;
68
68
let exportedModulesFromDeclarationEmit : Symbol [ ] | undefined ;
69
69
@@ -701,12 +701,12 @@ namespace ts {
701
701
}
702
702
}
703
703
704
- function isExternalModuleIndicator ( result : LateVisibilityPaintedStatement ) {
704
+ function isExternalModuleIndicator ( result : LateVisibilityPaintedStatement | ExportAssignment ) {
705
705
// Exported top-level member indicates moduleness
706
706
return isAnyImportOrReExport ( result ) || isExportAssignment ( result ) || hasModifier ( result , ModifierFlags . Export ) ;
707
707
}
708
708
709
- function needsScopeMarker ( result : LateVisibilityPaintedStatement ) {
709
+ function needsScopeMarker ( result : LateVisibilityPaintedStatement | ExportAssignment ) {
710
710
return ! isAnyImportOrReExport ( result ) && ! isExportAssignment ( result ) && ! hasModifier ( result , ModifierFlags . Export ) && ! isAmbientModule ( result ) ;
711
711
}
712
712
@@ -1047,7 +1047,43 @@ namespace ts {
1047
1047
return createVariableStatement ( /*modifiers*/ undefined , createVariableDeclarationList ( [ varDecl ] ) ) ;
1048
1048
} ) ;
1049
1049
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 ] ;
1051
1087
}
1052
1088
else {
1053
1089
return clean ;
0 commit comments