@@ -596,46 +596,48 @@ namespace ts.Completions {
596
596
isNewIdentifierLocation = false ;
597
597
598
598
// Since this is qualified name check its a type node location
599
- const isTypeLocation = isPartOfTypeNode ( node . parent ) || insideJsDocTagTypeExpression ;
599
+ const isTypeLocation = insideJsDocTagTypeExpression || isPartOfTypeNode ( node . parent ) ;
600
600
const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration ( node ) ;
601
- if ( node . kind === SyntaxKind . Identifier || node . kind === SyntaxKind . QualifiedName || node . kind === SyntaxKind . PropertyAccessExpression ) {
601
+ if ( isEntityName ( node ) ) {
602
602
let symbol = typeChecker . getSymbolAtLocation ( node ) ;
603
+ if ( symbol ) {
604
+ symbol = skipAlias ( symbol , typeChecker ) ;
605
+
606
+ if ( symbol . flags & ( SymbolFlags . Module | SymbolFlags . Enum ) ) {
607
+ // Extract module or enum members
608
+ const exportedSymbols = typeChecker . getExportsOfModule ( symbol ) ;
609
+ const isValidValueAccess = ( symbol : Symbol ) => typeChecker . isValidPropertyAccess ( < PropertyAccessExpression > ( node . parent ) , symbol . getUnescapedName ( ) ) ;
610
+ const isValidTypeAccess = ( symbol : Symbol ) => symbolCanBeReferencedAtTypeLocation ( symbol ) ;
611
+ const isValidAccess = isRhsOfImportDeclaration ?
612
+ // Any kind is allowed when dotting off namespace in internal import equals declaration
613
+ ( symbol : Symbol ) => isValidTypeAccess ( symbol ) || isValidValueAccess ( symbol ) :
614
+ isTypeLocation ? isValidTypeAccess : isValidValueAccess ;
615
+ for ( const symbol of exportedSymbols ) {
616
+ if ( isValidAccess ( symbol ) ) {
617
+ symbols . push ( symbol ) ;
618
+ }
619
+ }
603
620
604
- // This is an alias, follow what it aliases
605
- if ( symbol && symbol . flags & SymbolFlags . Alias ) {
606
- symbol = typeChecker . getAliasedSymbol ( symbol ) ;
607
- }
608
-
609
- if ( symbol && symbol . flags & SymbolFlags . HasExports ) {
610
- // Extract module or enum members
611
- const exportedSymbols = typeChecker . getExportsOfModule ( symbol ) ;
612
- const isValidValueAccess = ( symbol : Symbol ) => typeChecker . isValidPropertyAccess ( < PropertyAccessExpression > ( node . parent ) , symbol . getUnescapedName ( ) ) ;
613
- const isValidTypeAccess = ( symbol : Symbol ) => symbolCanBeReferencedAtTypeLocation ( symbol ) ;
614
- const isValidAccess = isRhsOfImportDeclaration ?
615
- // Any kind is allowed when dotting off namespace in internal import equals declaration
616
- ( symbol : Symbol ) => isValidTypeAccess ( symbol ) || isValidValueAccess ( symbol ) :
617
- isTypeLocation ? isValidTypeAccess : isValidValueAccess ;
618
- forEach ( exportedSymbols , symbol => {
619
- if ( isValidAccess ( symbol ) ) {
620
- symbols . push ( symbol ) ;
621
+ // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods).
622
+ if ( ! isTypeLocation && symbol . declarations . some ( d => d . kind !== SyntaxKind . SourceFile && d . kind !== SyntaxKind . ModuleDeclaration && d . kind !== SyntaxKind . EnumDeclaration ) ) {
623
+ addTypeProperties ( typeChecker . getTypeOfSymbolAtLocation ( symbol , node ) ) ;
621
624
}
622
- } ) ;
625
+
626
+ return ;
627
+ }
623
628
}
624
629
}
625
630
626
631
if ( ! isTypeLocation ) {
627
- const type = typeChecker . getTypeAtLocation ( node ) ;
628
- if ( type ) addTypeProperties ( type ) ;
632
+ addTypeProperties ( typeChecker . getTypeAtLocation ( node ) ) ;
629
633
}
630
634
}
631
635
632
636
function addTypeProperties ( type : Type ) {
633
- if ( type ) {
634
- // Filter private properties
635
- for ( const symbol of type . getApparentProperties ( ) ) {
636
- if ( typeChecker . isValidPropertyAccess ( < PropertyAccessExpression > ( node . parent ) , symbol . getUnescapedName ( ) ) ) {
637
- symbols . push ( symbol ) ;
638
- }
637
+ // Filter private properties
638
+ for ( const symbol of type . getApparentProperties ( ) ) {
639
+ if ( typeChecker . isValidPropertyAccess ( < PropertyAccessExpression > ( node . parent ) , symbol . getUnescapedName ( ) ) ) {
640
+ symbols . push ( symbol ) ;
639
641
}
640
642
}
641
643
@@ -811,15 +813,13 @@ namespace ts.Completions {
811
813
symbol = symbol . exportSymbol || symbol ;
812
814
813
815
// This is an alias, follow what it aliases
814
- if ( symbol && symbol . flags & SymbolFlags . Alias ) {
815
- symbol = typeChecker . getAliasedSymbol ( symbol ) ;
816
- }
816
+ symbol = skipAlias ( symbol , typeChecker ) ;
817
817
818
818
if ( symbol . flags & SymbolFlags . Type ) {
819
819
return true ;
820
820
}
821
821
822
- if ( symbol . flags & ( SymbolFlags . ValueModule | SymbolFlags . NamespaceModule ) ) {
822
+ if ( symbol . flags & SymbolFlags . Module ) {
823
823
const exportedSymbols = typeChecker . getExportsOfModule ( symbol ) ;
824
824
// If the exported symbols contains type,
825
825
// symbol can be referenced at locations where type is allowed
0 commit comments