@@ -105,10 +105,12 @@ module ts {
105
105
writeTypeParameter : writeTypeParameter ,
106
106
writeTypeParametersOfSymbol : writeTypeParametersOfSymbol ,
107
107
isImplementationOfOverload : isImplementationOfOverload ,
108
- getAliasedSymbol : resolveImport
108
+ getAliasedSymbol : resolveImport ,
109
+ isUndefinedSymbol : symbol => symbol === undefinedSymbol ,
110
+ isArgumentsSymbol : symbol => symbol === argumentsSymbol
109
111
} ;
110
112
111
- var undefinedSymbol = createSymbol ( SymbolFlags . Undefined | SymbolFlags . Property | SymbolFlags . Transient , "undefined" ) ;
113
+ var undefinedSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Transient , "undefined" ) ;
112
114
var argumentsSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Transient , "arguments" ) ;
113
115
var unknownSymbol = createSymbol ( SymbolFlags . Property | SymbolFlags . Transient , "unknown" ) ;
114
116
var resolvingSymbol = createSymbol ( SymbolFlags . Transient , "__resolving__" ) ;
@@ -737,7 +739,7 @@ module ts {
737
739
return rightMeaning === SymbolFlags . Value ? SymbolFlags . Value : SymbolFlags . Namespace ;
738
740
}
739
741
740
- function getAccessibleSymbolChain ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) : Symbol [ ] {
742
+ function getAccessibleSymbolChain ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags , useOnlyExternalAliasing : boolean ) : Symbol [ ] {
741
743
function getAccessibleSymbolChainFromSymbolTable ( symbols : SymbolTable ) : Symbol [ ] {
742
744
function canQualifySymbol ( symbolFromSymbolTable : Symbol , meaning : SymbolFlags ) {
743
745
// If the symbol is equivalent and doesn't need further qualification, this symbol is accessible
@@ -746,7 +748,7 @@ module ts {
746
748
}
747
749
748
750
// If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too
749
- var accessibleParent = getAccessibleSymbolChain ( symbolFromSymbolTable . parent , enclosingDeclaration , getQualifiedLeftMeaning ( meaning ) ) ;
751
+ var accessibleParent = getAccessibleSymbolChain ( symbolFromSymbolTable . parent , enclosingDeclaration , getQualifiedLeftMeaning ( meaning ) , useOnlyExternalAliasing ) ;
750
752
return ! ! accessibleParent ;
751
753
}
752
754
@@ -768,16 +770,21 @@ module ts {
768
770
// Check if symbol is any of the alias
769
771
return forEachValue ( symbols , symbolFromSymbolTable => {
770
772
if ( symbolFromSymbolTable . flags & SymbolFlags . Import ) {
771
- var resolvedImportedSymbol = resolveImport ( symbolFromSymbolTable ) ;
772
- if ( isAccessible ( symbolFromSymbolTable , resolveImport ( symbolFromSymbolTable ) ) ) {
773
- return [ symbolFromSymbolTable ] ;
774
- }
773
+ if ( ! useOnlyExternalAliasing || // We can use any type of alias to get the name
774
+ // Is this external alias, then use it to name
775
+ ts . forEach ( symbolFromSymbolTable . declarations , declaration =>
776
+ declaration . kind === SyntaxKind . ImportDeclaration && ( < ImportDeclaration > declaration ) . externalModuleName ) ) {
777
+ var resolvedImportedSymbol = resolveImport ( symbolFromSymbolTable ) ;
778
+ if ( isAccessible ( symbolFromSymbolTable , resolveImport ( symbolFromSymbolTable ) ) ) {
779
+ return [ symbolFromSymbolTable ] ;
780
+ }
775
781
776
- // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
777
- // but only if the symbolFromSymbolTable can be qualified
778
- var accessibleSymbolsFromExports = resolvedImportedSymbol . exports ? getAccessibleSymbolChainFromSymbolTable ( resolvedImportedSymbol . exports ) : undefined ;
779
- if ( accessibleSymbolsFromExports && canQualifySymbol ( symbolFromSymbolTable , getQualifiedLeftMeaning ( meaning ) ) ) {
780
- return [ symbolFromSymbolTable ] . concat ( accessibleSymbolsFromExports ) ;
782
+ // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
783
+ // but only if the symbolFromSymbolTable can be qualified
784
+ var accessibleSymbolsFromExports = resolvedImportedSymbol . exports ? getAccessibleSymbolChainFromSymbolTable ( resolvedImportedSymbol . exports ) : undefined ;
785
+ if ( accessibleSymbolsFromExports && canQualifySymbol ( symbolFromSymbolTable , getQualifiedLeftMeaning ( meaning ) ) ) {
786
+ return [ symbolFromSymbolTable ] . concat ( accessibleSymbolsFromExports ) ;
787
+ }
781
788
}
782
789
}
783
790
} ) ;
@@ -823,7 +830,7 @@ module ts {
823
830
var meaningToLook = meaning ;
824
831
while ( symbol ) {
825
832
// Symbol is accessible if it by itself is accessible
826
- var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaningToLook ) ;
833
+ var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaningToLook , /*useOnlyExternalAliasing*/ false ) ;
827
834
if ( accessibleSymbolChain ) {
828
835
var hasAccessibleDeclarations = hasVisibleDeclarations ( accessibleSymbolChain [ 0 ] ) ;
829
836
if ( ! hasAccessibleDeclarations ) {
@@ -1006,7 +1013,7 @@ module ts {
1006
1013
writer . trackSymbol ( symbol , enclosingDeclaration , meaning ) ;
1007
1014
function walkSymbol ( symbol : Symbol , meaning : SymbolFlags ) : void {
1008
1015
if ( symbol ) {
1009
- var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaning ) ;
1016
+ var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaning , ! ! ( flags & SymbolFormatFlags . UseOnlyExternalAliasing ) ) ;
1010
1017
1011
1018
if ( ! accessibleSymbolChain ||
1012
1019
needsQualification ( accessibleSymbolChain [ 0 ] , enclosingDeclaration , accessibleSymbolChain . length === 1 ? meaning : getQualifiedLeftMeaning ( meaning ) ) ) {
0 commit comments