Skip to content

Commit eb9d4c0

Browse files
author
Andy Hanson
committed
findAllReferences: Given a synthetic property, find references for the original property.
1 parent 47bd4d3 commit eb9d4c0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ namespace ts.FindAllReferences.Core {
273273
}
274274
}
275275

276-
const symbol = checker.getSymbolAtLocation(node);
276+
let symbol = checker.getSymbolAtLocation(node);
277277

278278
// Could not find a symbol e.g. unknown identifier
279279
if (!symbol) {
@@ -285,6 +285,9 @@ namespace ts.FindAllReferences.Core {
285285
return undefined;
286286
}
287287

288+
// If this property is derived from another one, find references on the original property instead.
289+
symbol = (symbol as ts.SymbolLinks).syntheticOrigin || symbol;
290+
288291
// The symbol was an internal symbol and does not have a declaration e.g. undefined symbol
289292
if (!symbol.declarations || !symbol.declarations.length) {
290293
return undefined;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; }
4+
////type U = { readonly [K in keyof T]?: string };
5+
////declare const t: T;
6+
////t.[|a|];
7+
////declare const u: U;
8+
////u.[|a|];
9+
10+
verify.singleReferenceGroup("(property) T.a: number");

0 commit comments

Comments
 (0)