File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -187,7 +187,15 @@ namespace ts.GoToDefinition {
187187 }
188188
189189 function isSignatureDeclaration ( node : Node ) : boolean {
190- return node . kind === SyntaxKind . FunctionDeclaration || node . kind === SyntaxKind . MethodDeclaration || node . kind === SyntaxKind . MethodSignature
190+ switch ( node . kind ) {
191+ case ts . SyntaxKind . Constructor :
192+ case ts . SyntaxKind . FunctionDeclaration :
193+ case ts . SyntaxKind . MethodDeclaration :
194+ case ts . SyntaxKind . MethodSignature :
195+ return true ;
196+ default :
197+ return false ;
198+ }
191199 }
192200
193201 /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
@@ -254,6 +262,11 @@ namespace ts.GoToDefinition {
254262
255263 function tryGetSignatureDeclaration ( typeChecker : TypeChecker , node : Node ) : SignatureDeclaration | undefined {
256264 const callLike = getAncestorCallLikeExpression ( node ) ;
257- return callLike && typeChecker . getResolvedSignature ( callLike ) . declaration ;
265+ const decl = callLike && typeChecker . getResolvedSignature ( callLike ) . declaration ;
266+ if ( decl && isSignatureDeclaration ( decl ) ) {
267+ return decl ;
268+ }
269+ // Don't go to a function type, go to the value having that type.
270+ return undefined ;
258271 }
259272}
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts'/>
2+
3+ // Tests that goToDefinition does not go to a function type; it goes to the value.
4+
5+ ////const /*constDefinition*/c: () => void;
6+ /////*constReference*/c();
7+ ////function test(/*cbDefinition*/cb: () => void) {
8+ //// /*cbReference*/cb();
9+ //// }
10+ ////class C {
11+ //// /*propDefinition*/prop: () => void;
12+ //// m() {
13+ //// this./*propReference*/prop();
14+ //// }
15+ //// }
16+
17+ verify . goToDefinitionForMarkers ( "const" , "cb" , "prop" ) ;
You can’t perform that action at this time.
0 commit comments