From 955604d2476dcf1125b4aeacc32162f083686fbc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 17 Apr 2018 10:46:14 -0700 Subject: [PATCH] goToDefinition: Remove isSignatureDeclaration, use isFunctionLike --- src/services/goToDefinition.ts | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 226fe74ef10c2..d3a0492aae15c 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -213,26 +213,13 @@ namespace ts.GoToDefinition { if (!signatureDeclarations) { return undefined; } - const declarations = signatureDeclarations.filter(selectConstructors ? isConstructorDeclaration : isSignatureDeclaration); + const declarations = signatureDeclarations.filter(selectConstructors ? isConstructorDeclaration : isFunctionLike); return declarations.length ? [createDefinitionInfo(find(declarations, d => !!(d).body) || last(declarations), symbolKind, symbolName, containerName)] : undefined; } } - function isSignatureDeclaration(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.Constructor: - case SyntaxKind.ConstructSignature: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - return true; - default: - return false; - } - } - /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo { return createDefinitionInfoFromName(getNameOfDeclaration(node) || node, symbolKind, symbolName, containerName); @@ -298,13 +285,7 @@ namespace ts.GoToDefinition { function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { const callLike = getAncestorCallLikeExpression(node); const signature = callLike && typeChecker.getResolvedSignature(callLike); - if (signature) { - const decl = signature.declaration; - if (decl && isSignatureDeclaration(decl)) { - return decl; - } - } // Don't go to a function type, go to the value having that type. - return undefined; + return tryCast(signature && signature.declaration, (d): d is SignatureDeclaration => isFunctionLike(d) && !isFunctionTypeNode(d)); } }