Skip to content

Commit f6510bd

Browse files
author
Andy
authored
goToDefinition: Remove isSignatureDeclaration, use isFunctionLike (#23475)
1 parent 0c17a2b commit f6510bd

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/services/goToDefinition.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,13 @@ namespace ts.GoToDefinition {
203203
if (!signatureDeclarations) {
204204
return undefined;
205205
}
206-
const declarations = signatureDeclarations.filter(selectConstructors ? isConstructorDeclaration : isSignatureDeclaration);
206+
const declarations = signatureDeclarations.filter(selectConstructors ? isConstructorDeclaration : isFunctionLike);
207207
return declarations.length
208208
? [createDefinitionInfo(find(declarations, d => !!(<FunctionLikeDeclaration>d).body) || last(declarations), typeChecker, symbol, node)]
209209
: undefined;
210210
}
211211
}
212212

213-
function isSignatureDeclaration(node: Node): boolean {
214-
switch (node.kind) {
215-
case SyntaxKind.Constructor:
216-
case SyntaxKind.ConstructSignature:
217-
case SyntaxKind.FunctionDeclaration:
218-
case SyntaxKind.MethodDeclaration:
219-
case SyntaxKind.MethodSignature:
220-
return true;
221-
default:
222-
return false;
223-
}
224-
}
225-
226213
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
227214
function createDefinitionInfo(declaration: Declaration, checker: TypeChecker, symbol: Symbol, node: Node): DefinitionInfo {
228215
const symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
@@ -278,13 +265,7 @@ namespace ts.GoToDefinition {
278265
function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined {
279266
const callLike = getAncestorCallLikeExpression(node);
280267
const signature = callLike && typeChecker.getResolvedSignature(callLike);
281-
if (signature) {
282-
const decl = signature.declaration;
283-
if (decl && isSignatureDeclaration(decl)) {
284-
return decl;
285-
}
286-
}
287268
// Don't go to a function type, go to the value having that type.
288-
return undefined;
269+
return tryCast(signature && signature.declaration, (d): d is SignatureDeclaration => isFunctionLike(d) && !isFunctionTypeNode(d));
289270
}
290271
}

0 commit comments

Comments
 (0)