@@ -356,7 +356,7 @@ namespace ts.FindAllReferences.Core {
356
356
357
357
/** Core find-all-references algorithm for a normal symbol. */
358
358
function getReferencedSymbolsForSymbol ( symbol : Symbol , node : Node , sourceFiles : ReadonlyArray < SourceFile > , checker : TypeChecker , cancellationToken : CancellationToken , options : Options ) : SymbolAndEntries [ ] {
359
- symbol = skipPastExportOrImportSpecifier ( symbol , node , checker ) ;
359
+ symbol = skipPastExportOrImportSpecifierOrUnion ( symbol , node , checker ) ;
360
360
361
361
// Compute the meaning from the location and the symbol it references
362
362
const searchMeaning = getIntersectingMeaningFromDeclarations ( getMeaningFromLocation ( node ) , symbol . declarations ) ;
@@ -405,7 +405,7 @@ namespace ts.FindAllReferences.Core {
405
405
}
406
406
407
407
/** Handle a few special cases relating to export/import specifiers. */
408
- function skipPastExportOrImportSpecifier ( symbol : Symbol , node : Node , checker : TypeChecker ) : Symbol {
408
+ function skipPastExportOrImportSpecifierOrUnion ( symbol : Symbol , node : Node , checker : TypeChecker ) : Symbol {
409
409
const { parent } = node ;
410
410
if ( isExportSpecifier ( parent ) ) {
411
411
return getLocalSymbolForExportSpecifier ( node as Identifier , symbol , parent , checker ) ;
@@ -415,7 +415,11 @@ namespace ts.FindAllReferences.Core {
415
415
return checker . getImmediateAliasedSymbol ( symbol ) ;
416
416
}
417
417
418
- return symbol ;
418
+ // If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references.
419
+ return firstDefined ( symbol . declarations , decl =>
420
+ isTypeLiteralNode ( decl . parent ) && isUnionTypeNode ( decl . parent . parent )
421
+ ? checker . getPropertyOfType ( checker . getTypeFromTypeNode ( decl . parent . parent ) , symbol . name )
422
+ : undefined ) || symbol ;
419
423
}
420
424
421
425
/**
0 commit comments