Find method references through base abstract classes implementing an interface (#61234)

This commit is contained in:
Mateusz Burzyński
2025-02-21 20:08:34 +01:00
committed by GitHub
parent b95187d1ce
commit edc497bb2b
3 changed files with 529 additions and 2 deletions

View File

@@ -2679,9 +2679,10 @@ export namespace Core {
return firstDefined(symbol.declarations, declaration =>
firstDefined(getAllSuperTypeNodes(declaration), typeReference => {
const type = checker.getTypeAtLocation(typeReference);
const propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName);
const propertySymbol = type.symbol && checker.getPropertyOfType(type, propertyName);
// Visit the typeReference as well to see if it directly or indirectly uses that property
return type && propertySymbol && (firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol));
// When `propertySymbol` is missing continue the recursion through parents as some parent up the chain might be an abstract class that implements interface having the property
return propertySymbol && firstDefined(checker.getRootSymbols(propertySymbol), cb) || type.symbol && recur(type.symbol);
}));
}
}