@@ -564,7 +564,7 @@ namespace ts {
564
564
// and this case is specially handled. Module augmentations should only be merged with original module definition
565
565
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
566
566
if ( isJSDocTypeAlias ( node ) ) Debug . assert ( isInJSFile ( node ) ) ; // We shouldn't add symbols for JSDoc nodes if not in a JS file.
567
- if ( ( ! isAmbientModule ( node ) && ( hasExportModifier || container . flags & NodeFlags . ExportContext ) ) || ( isJSDocTypeAlias ( node ) && container . symbol ) ) {
567
+ if ( ( ! isAmbientModule ( node ) && ( hasExportModifier || container . flags & NodeFlags . ExportContext ) ) || isJSDocTypeAlias ( node ) ) {
568
568
if ( ! container . locals || ( hasModifier ( node , ModifierFlags . Default ) && ! getDeclarationName ( node ) ) ) {
569
569
return declareSymbol ( container . symbol . exports ! , container . symbol , node , symbolFlags , symbolExcludes ) ; // No local symbol for an unnamed default!
570
570
}
@@ -2003,7 +2003,12 @@ namespace ts {
2003
2003
switch ( getAssignmentDeclarationPropertyAccessKind ( declName . parent ) ) {
2004
2004
case AssignmentDeclarationKind . ExportsProperty :
2005
2005
case AssignmentDeclarationKind . ModuleExports :
2006
- container = file ;
2006
+ if ( ! isExternalOrCommonJsModule ( file ) ) {
2007
+ container = undefined ! ;
2008
+ }
2009
+ else {
2010
+ container = file ;
2011
+ }
2007
2012
break ;
2008
2013
case AssignmentDeclarationKind . ThisProperty :
2009
2014
container = declName . parent . expression ;
@@ -2017,7 +2022,9 @@ namespace ts {
2017
2022
case AssignmentDeclarationKind . None :
2018
2023
return Debug . fail ( "Shouldn't have detected typedef or enum on non-assignment declaration" ) ;
2019
2024
}
2020
- declareModuleMember ( typeAlias , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
2025
+ if ( container ) {
2026
+ declareModuleMember ( typeAlias , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
2027
+ }
2021
2028
container = oldContainer ;
2022
2029
}
2023
2030
}
0 commit comments