Skip to content

Commit 33fe401

Browse files
Merge pull request #836 from Microsoft/handleAliasedTypes
Handle findAllRefs/getOccurrences for properties inherited from aliased types
2 parents e2c4d7d + bc8c6c9 commit 33fe401

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/services/services.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ module ts {
35443544
}
35453545

35463546
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[]): void {
3547-
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
3547+
if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
35483548
forEach(symbol.getDeclarations(), declaration => {
35493549
if (declaration.kind === SyntaxKind.ClassDeclaration) {
35503550
getPropertySymbolFromTypeReference((<ClassDeclaration>declaration).baseType);
@@ -3559,14 +3559,15 @@ module ts {
35593559

35603560
function getPropertySymbolFromTypeReference(typeReference: TypeReferenceNode) {
35613561
if (typeReference) {
3562-
// TODO: move to getTypeOfNode instead
3563-
var typeReferenceSymbol = typeInfoResolver.getSymbolInfo(typeReference.typeName);
3564-
if (typeReferenceSymbol) {
3565-
var propertySymbol = typeReferenceSymbol.members[propertyName];
3566-
if (propertySymbol) result.push(typeReferenceSymbol.members[propertyName]);
3562+
var type = typeInfoResolver.getTypeOfNode(typeReference);
3563+
if (type) {
3564+
var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
3565+
if (propertySymbol) {
3566+
result.push(propertySymbol);
3567+
}
35673568

35683569
// Visit the typeReference as well to see if it directly or indirectly use that property
3569-
getPropertySymbolsFromBaseTypes(typeReferenceSymbol, propertyName, result);
3570+
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result);
35703571
}
35713572
}
35723573
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
////module m {
2+
//// export interface Foo {
3+
//// [|abc|]
4+
//// }
5+
////}
6+
////
7+
////import Bar = m.Foo;
8+
////
9+
////export interface I extends Bar {
10+
//// [|abc|]
11+
////}
12+
////
13+
////class C implements Bar {
14+
//// [|abc|]
15+
////}
16+
////
17+
////(new C()).[|abc|];
18+
19+
test.ranges().forEach(r => {
20+
goTo.position(r.start);
21+
22+
test.ranges().forEach(range => {
23+
verify.occurrencesAtPositionContains(range);
24+
});
25+
verify.occurrencesAtPositionCount(test.ranges().length);
26+
});

0 commit comments

Comments
 (0)