@@ -1509,7 +1509,7 @@ namespace ts {
1509
1509
errorOnFirstToken ( node , Diagnostics . export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible ) ;
1510
1510
}
1511
1511
if ( isExternalModuleAugmentation ( node ) ) {
1512
- declareSymbolAndAddToSymbolTable ( node , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes ) ;
1512
+ declareModuleSymbol ( node ) ;
1513
1513
}
1514
1514
else {
1515
1515
let pattern : Pattern | undefined ;
@@ -1531,12 +1531,8 @@ namespace ts {
1531
1531
}
1532
1532
}
1533
1533
else {
1534
- const state = getModuleInstanceState ( node ) ;
1535
- if ( state === ModuleInstanceState . NonInstantiated ) {
1536
- declareSymbolAndAddToSymbolTable ( node , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes ) ;
1537
- }
1538
- else {
1539
- declareSymbolAndAddToSymbolTable ( node , SymbolFlags . ValueModule , SymbolFlags . ValueModuleExcludes ) ;
1534
+ const state = declareModuleSymbol ( node ) ;
1535
+ if ( state !== ModuleInstanceState . NonInstantiated ) {
1540
1536
if ( node . symbol . flags & ( SymbolFlags . Function | SymbolFlags . Class | SymbolFlags . RegularEnum ) ) {
1541
1537
// if module was already merged with some function, class or non-const enum
1542
1538
// treat is a non-const-enum-only
@@ -1557,6 +1553,15 @@ namespace ts {
1557
1553
}
1558
1554
}
1559
1555
1556
+ function declareModuleSymbol ( node : ModuleDeclaration ) : ModuleInstanceState {
1557
+ const state = getModuleInstanceState ( node ) ;
1558
+ const instantiated = state !== ModuleInstanceState . NonInstantiated ;
1559
+ declareSymbolAndAddToSymbolTable ( node ,
1560
+ instantiated ? SymbolFlags . ValueModule : SymbolFlags . NamespaceModule ,
1561
+ instantiated ? SymbolFlags . ValueModuleExcludes : SymbolFlags . NamespaceModuleExcludes ) ;
1562
+ return state ;
1563
+ }
1564
+
1560
1565
function bindFunctionOrConstructorType ( node : SignatureDeclaration ) : void {
1561
1566
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
1562
1567
// to the one we would get for: { <...>(...): T }
0 commit comments