@@ -1435,22 +1435,27 @@ namespace ts.FindAllReferences.Core {
1435
1435
const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName ( symbol , checker ) ;
1436
1436
if ( bindingElementPropertySymbol ) {
1437
1437
result . push ( bindingElementPropertySymbol ) ;
1438
+ addRootSymbols ( bindingElementPropertySymbol ) ;
1438
1439
}
1439
1440
1440
- // If this is a union property, add all the symbols from all its source symbols in all unioned types.
1441
- // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
1442
- for ( const rootSymbol of checker . getRootSymbols ( symbol ) ) {
1443
- if ( rootSymbol !== symbol ) {
1444
- result . push ( rootSymbol ) ;
1445
- }
1441
+ addRootSymbols ( symbol ) ;
1442
+
1443
+ return result ;
1444
+
1445
+ function addRootSymbols ( sym : Symbol ) : void {
1446
+ // If this is a union property, add all the symbols from all its source symbols in all unioned types.
1447
+ // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
1448
+ for ( const rootSymbol of checker . getRootSymbols ( sym ) ) {
1449
+ if ( rootSymbol !== sym ) {
1450
+ result . push ( rootSymbol ) ;
1451
+ }
1446
1452
1447
- // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
1448
- if ( ! implementations && rootSymbol . parent && rootSymbol . parent . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) ) {
1449
- getPropertySymbolsFromBaseTypes ( rootSymbol . parent , rootSymbol . name , result , /*previousIterationSymbolsCache*/ createSymbolTable ( ) , checker ) ;
1453
+ // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
1454
+ if ( ! implementations && rootSymbol . parent && rootSymbol . parent . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) ) {
1455
+ getPropertySymbolsFromBaseTypes ( rootSymbol . parent , rootSymbol . name , result , /*previousIterationSymbolsCache*/ createSymbolTable ( ) , checker ) ;
1456
+ }
1450
1457
}
1451
1458
}
1452
-
1453
- return result ;
1454
1459
}
1455
1460
1456
1461
/**
@@ -1542,34 +1547,39 @@ namespace ts.FindAllReferences.Core {
1542
1547
// then include the binding element in the related symbols
1543
1548
// let { a } : { a };
1544
1549
const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName ( referenceSymbol , state . checker ) ;
1545
- if ( bindingElementPropertySymbol && search . includes ( bindingElementPropertySymbol ) ) {
1546
- return bindingElementPropertySymbol ;
1550
+ if ( bindingElementPropertySymbol ) {
1551
+ const fromBindingElement = findRootSymbol ( bindingElementPropertySymbol ) ;
1552
+ if ( fromBindingElement ) return fromBindingElement ;
1547
1553
}
1548
1554
1549
- // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
1550
- // Or a union property, use its underlying unioned symbols
1551
- return forEach ( state . checker . getRootSymbols ( referenceSymbol ) , rootSymbol => {
1552
- // if it is in the list, then we are done
1553
- if ( search . includes ( rootSymbol ) ) {
1554
- return rootSymbol ;
1555
- }
1555
+ return findRootSymbol ( referenceSymbol ) ;
1556
1556
1557
- // Finally, try all properties with the same name in any type the containing type extended or implemented, and
1558
- // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the
1559
- // parent symbol
1560
- if ( rootSymbol . parent && rootSymbol . parent . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) ) {
1561
- // Parents will only be defined if implementations is true
1562
- if ( search . parents && ! some ( search . parents , parent => explicitlyInheritsFrom ( rootSymbol . parent , parent , state . inheritsFromCache , state . checker ) ) ) {
1563
- return undefined ;
1557
+ function findRootSymbol ( sym : Symbol ) : Symbol | undefined {
1558
+ // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
1559
+ // Or a union property, use its underlying unioned symbols
1560
+ return forEach ( state . checker . getRootSymbols ( sym ) , rootSymbol => {
1561
+ // if it is in the list, then we are done
1562
+ if ( search . includes ( rootSymbol ) ) {
1563
+ return rootSymbol ;
1564
1564
}
1565
1565
1566
- const result : Symbol [ ] = [ ] ;
1567
- getPropertySymbolsFromBaseTypes ( rootSymbol . parent , rootSymbol . name , result , /*previousIterationSymbolsCache*/ createSymbolTable ( ) , state . checker ) ;
1568
- return find ( result , search . includes ) ;
1569
- }
1566
+ // Finally, try all properties with the same name in any type the containing type extended or implemented, and
1567
+ // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the
1568
+ // parent symbol
1569
+ if ( rootSymbol . parent && rootSymbol . parent . flags & ( SymbolFlags . Class | SymbolFlags . Interface ) ) {
1570
+ // Parents will only be defined if implementations is true
1571
+ if ( search . parents && ! some ( search . parents , parent => explicitlyInheritsFrom ( rootSymbol . parent , parent , state . inheritsFromCache , state . checker ) ) ) {
1572
+ return undefined ;
1573
+ }
1570
1574
1571
- return undefined ;
1572
- } ) ;
1575
+ const result : Symbol [ ] = [ ] ;
1576
+ getPropertySymbolsFromBaseTypes ( rootSymbol . parent , rootSymbol . name , result , /*previousIterationSymbolsCache*/ createSymbolTable ( ) , state . checker ) ;
1577
+ return find ( result , search . includes ) ;
1578
+ }
1579
+
1580
+ return undefined ;
1581
+ } ) ;
1582
+ }
1573
1583
}
1574
1584
1575
1585
function getNameFromObjectLiteralElement ( node : ObjectLiteralElement ) : string {
0 commit comments