Skip to content

Commit 0e5af11

Browse files
author
Andy
authored
Fix bugs for go-to-definition on mapped type method (microsoft#25991)
1 parent 998c911 commit 0e5af11

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/services/goToDefinition.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ namespace ts.GoToDefinition {
3434
// For a function, if this is the original function definition, return just sigInfo.
3535
// If this is the original constructor definition, parent is the class.
3636
if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration)) ||
37-
// TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias
38-
symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) {
37+
// TODO: GH#25533 Following check shouldn't be necessary if 'require' is an alias
38+
symbol.declarations && symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) {
3939
return [sigInfo];
4040
}
4141
else {
42-
const defs = getDefinitionFromSymbol(typeChecker, symbol, node)!;
42+
const defs = getDefinitionFromSymbol(typeChecker, symbol, node) || emptyArray;
4343
// For a 'super()' call, put the signature first, else put the variable first.
4444
return node.kind === SyntaxKind.SuperKeyword ? [sigInfo, ...defs] : [...defs, sigInfo];
4545
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
///<reference path="fourslash.ts"/>
2+
3+
////interface I { /*def*/m(): void; };
4+
////declare const i: { [K in "m"]: I[K] };
5+
////i.[|/*ref*/m|]();
6+
7+
verify.goToDefinition("ref", "def");

0 commit comments

Comments
 (0)