@@ -92,20 +92,27 @@ export class DeclarationReferenceGenerator {
92
92
const sourceFile : ts . SourceFile | undefined = declaration ?. getSourceFile ( ) ;
93
93
const parent : ts . Symbol | undefined = TypeScriptInternals . getSymbolParent ( symbol ) ;
94
94
95
- // If it's a global, then use an Exports navigation.
96
- if ( sourceFile && ! ts . isExternalModule ( sourceFile ) ) {
97
- return Navigation . Exports ;
98
- }
95
+ // If it's global or from an external library, then use either Members or Exports. It's not possible for
96
+ // global symbols or external library symbols to be Locals.
97
+ const isGlobal : boolean = ! ! sourceFile && ! ts . isExternalModule ( sourceFile ) ;
98
+ const isFromExternalLibrary : boolean =
99
+ ! ! sourceFile && this . _collector . program . isSourceFileFromExternalLibrary ( sourceFile ) ;
100
+ if ( isGlobal || isFromExternalLibrary ) {
101
+ if (
102
+ parent &&
103
+ parent . members &&
104
+ DeclarationReferenceGenerator . _isSameSymbol ( parent . members . get ( symbol . escapedName ) , symbol )
105
+ ) {
106
+ return Navigation . Members ;
107
+ }
99
108
100
- // If it's from an external library, then use an Exports navigation.
101
- if ( sourceFile && this . _collector . program . isSourceFileFromExternalLibrary ( sourceFile ) ) {
102
109
return Navigation . Exports ;
103
110
}
104
111
105
112
// Otherwise, this symbol is from the current package.
106
113
if ( parent ) {
107
114
// If we've found an exported CollectorEntity, then it's exported from the package entry point, so
108
- // use an Exports navigation .
115
+ // use Exports.
109
116
const namedDeclaration : ts . DeclarationName | undefined = (
110
117
declaration as ts . NamedDeclaration | undefined
111
118
) ?. name ;
@@ -117,10 +124,17 @@ export class DeclarationReferenceGenerator {
117
124
}
118
125
}
119
126
120
- // If its parent symbol is not a source file, then use an Exports navigation . If the parent symbol is
121
- // a source file, but it wasn't exported from the package entry point (in the check above), then the symbol
122
- // is a local, so fall through below.
127
+ // If its parent symbol is not a source file, then use either Exports or Members . If the parent symbol
128
+ // is a source file, but it wasn't exported from the package entry point (in the check above), then the
129
+ // symbol is a local, so fall through below.
123
130
if ( ! DeclarationReferenceGenerator . _isExternalModuleSymbol ( parent ) ) {
131
+ if (
132
+ parent . members &&
133
+ DeclarationReferenceGenerator . _isSameSymbol ( parent . members . get ( symbol . escapedName ) , symbol )
134
+ ) {
135
+ return Navigation . Members ;
136
+ }
137
+
124
138
return Navigation . Exports ;
125
139
}
126
140
}
0 commit comments