Fix bugs for go-to-definition on mapped type method (#25991)

This commit is contained in:
Andy 2018-07-26 17:26:41 -07:00 committed by GitHub
parent 998c911c49
commit 0e5af11625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -34,12 +34,12 @@ namespace ts.GoToDefinition {
// For a function, if this is the original function definition, return just sigInfo.
// If this is the original constructor definition, parent is the class.
if (typeChecker.getRootSymbols(symbol).some(s => symbolMatchesSignature(s, calledDeclaration)) ||
// TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias
symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) {
// TODO: GH#25533 Following check shouldn't be necessary if 'require' is an alias
symbol.declarations && symbol.declarations.some(d => isVariableDeclaration(d) && !!d.initializer && isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false))) {
return [sigInfo];
}
else {
const defs = getDefinitionFromSymbol(typeChecker, symbol, node)!;
const defs = getDefinitionFromSymbol(typeChecker, symbol, node) || emptyArray;
// For a 'super()' call, put the signature first, else put the variable first.
return node.kind === SyntaxKind.SuperKeyword ? [sigInfo, ...defs] : [...defs, sigInfo];
}

View File

@ -0,0 +1,7 @@
///<reference path="fourslash.ts"/>
////interface I { /*def*/m(): void; };
////declare const i: { [K in "m"]: I[K] };
////i.[|/*ref*/m|]();
verify.goToDefinition("ref", "def");