@@ -51,7 +51,7 @@ export class DeclarationReferenceGenerator {
5151 ) : DeclarationReference | undefined {
5252 return this . _symbolToDeclarationReference ( symbol , meaning , /*includeModuleSymbols*/ false ) ;
5353 }
54-
54+
5555 private static _isInExpressionContext ( node : ts . Node ) : boolean {
5656 switch ( node . parent . kind ) {
5757 case ts . SyntaxKind . TypeQuery : return true ;
@@ -177,39 +177,41 @@ export class DeclarationReferenceGenerator {
177177
178178 private _symbolToDeclarationReference ( symbol : ts . Symbol , meaning : ts . SymbolFlags , includeModuleSymbols : boolean
179179 ) : DeclarationReference | undefined {
180- if ( symbol . flags & ts . SymbolFlags . ExportValue ) {
181- symbol = this . _typeChecker . getExportSymbolOfSymbol ( symbol ) ;
180+
181+ let followedSymbol : ts . Symbol = symbol ;
182+ if ( followedSymbol . flags & ts . SymbolFlags . ExportValue ) {
183+ followedSymbol = this . _typeChecker . getExportSymbolOfSymbol ( followedSymbol ) ;
182184 }
183- if ( symbol . flags & ts . SymbolFlags . Alias ) {
184- symbol = this . _typeChecker . getAliasedSymbol ( symbol ) ;
185+ if ( followedSymbol . flags & ts . SymbolFlags . Alias ) {
186+ followedSymbol = this . _typeChecker . getAliasedSymbol ( followedSymbol ) ;
185187 }
186188
187- if ( DeclarationReferenceGenerator . _isExternalModuleSymbol ( symbol ) ) {
189+ if ( DeclarationReferenceGenerator . _isExternalModuleSymbol ( followedSymbol ) ) {
188190 if ( ! includeModuleSymbols ) {
189191 return undefined ;
190192 }
191193 const sourceFile : ts . SourceFile | undefined =
192- symbol . declarations
193- && symbol . declarations [ 0 ]
194- && symbol . declarations [ 0 ] . getSourceFile ( ) ;
194+ followedSymbol . declarations
195+ && followedSymbol . declarations [ 0 ]
196+ && followedSymbol . declarations [ 0 ] . getSourceFile ( ) ;
195197 return new DeclarationReference ( this . _sourceFileToModuleSource ( sourceFile ) ) ;
196198 }
197199
198200 // Do not generate a declaration reference for a type parameter.
199- if ( symbol . flags & ts . SymbolFlags . TypeParameter ) {
201+ if ( followedSymbol . flags & ts . SymbolFlags . TypeParameter ) {
200202 return undefined ;
201203 }
202204
203- const parent : ts . Symbol | undefined = TypeScriptInternals . getSymbolParent ( symbol ) ;
205+ const parent : ts . Symbol | undefined = TypeScriptInternals . getSymbolParent ( followedSymbol ) ;
204206 let parentRef : DeclarationReference | undefined ;
205207 if ( parent ) {
206208 parentRef = this . _symbolToDeclarationReference ( parent , ts . SymbolFlags . Namespace , /*includeModuleSymbols*/ true ) ;
207209 } else {
208210 // this may be a local symbol in a module...
209211 const sourceFile : ts . SourceFile | undefined =
210- symbol . declarations
211- && symbol . declarations [ 0 ]
212- && symbol . declarations [ 0 ] . getSourceFile ( ) ;
212+ followedSymbol . declarations
213+ && followedSymbol . declarations [ 0 ]
214+ && followedSymbol . declarations [ 0 ] . getSourceFile ( ) ;
213215 if ( ts . isExternalModule ( sourceFile ) ) {
214216 parentRef = new DeclarationReference ( this . _sourceFileToModuleSource ( sourceFile ) ) ;
215217 } else {
@@ -221,17 +223,17 @@ export class DeclarationReferenceGenerator {
221223 return undefined ;
222224 }
223225
224- let localName : string = symbol . name ;
225- if ( symbol . escapedName === ts . InternalSymbolName . Constructor ) {
226+ let localName : string = followedSymbol . name ;
227+ if ( followedSymbol . escapedName === ts . InternalSymbolName . Constructor ) {
226228 localName = 'constructor' ;
227229 } else {
228- const wellKnownName : string | undefined = TypeScriptHelpers . tryDecodeWellKnownSymbolName ( symbol . escapedName ) ;
230+ const wellKnownName : string | undefined = TypeScriptHelpers . tryDecodeWellKnownSymbolName ( followedSymbol . escapedName ) ;
229231 if ( wellKnownName ) {
230232 // TypeScript binds well-known ECMAScript symbols like 'Symbol.iterator' as '__@iterator'.
231233 // This converts a string like '__@iterator' into the property name '[Symbol.iterator]'.
232234 localName = wellKnownName ;
233- } else if ( TypeScriptHelpers . isUniqueSymbolName ( symbol . escapedName ) ) {
234- for ( const decl of symbol . declarations || [ ] ) {
235+ } else if ( TypeScriptHelpers . isUniqueSymbolName ( followedSymbol . escapedName ) ) {
236+ for ( const decl of followedSymbol . declarations || [ ] ) {
235237 const declName : ts . DeclarationName | undefined = ts . getNameOfDeclaration ( decl ) ;
236238 if ( declName && ts . isComputedPropertyName ( declName ) ) {
237239 const lateName : string | undefined = TypeScriptHelpers . tryGetLateBoundName ( declName ) ;
@@ -244,7 +246,7 @@ export class DeclarationReferenceGenerator {
244246 }
245247 }
246248
247- let navigation : Navigation | 'global' = DeclarationReferenceGenerator . _getNavigationToSymbol ( symbol ) ;
249+ let navigation : Navigation | 'global' = DeclarationReferenceGenerator . _getNavigationToSymbol ( followedSymbol ) ;
248250 if ( navigation === 'global' ) {
249251 if ( parentRef . source !== GlobalSource . instance ) {
250252 parentRef = new DeclarationReference ( GlobalSource . instance ) ;
@@ -254,7 +256,7 @@ export class DeclarationReferenceGenerator {
254256
255257 return parentRef
256258 . addNavigationStep ( navigation , localName )
257- . withMeaning ( DeclarationReferenceGenerator . _getMeaningOfSymbol ( symbol , meaning ) ) ;
259+ . withMeaning ( DeclarationReferenceGenerator . _getMeaningOfSymbol ( followedSymbol , meaning ) ) ;
258260 }
259261
260262 private _getPackageName ( sourceFile : ts . SourceFile ) : string {
0 commit comments