@@ -32,7 +32,7 @@ namespace ts.GoToDefinition {
3232 const sigInfo = createDefinitionFromSignatureDeclaration ( typeChecker , calledDeclaration ) ;
3333 // For a function, if this is the original function definition, return just sigInfo.
3434 // If this is the original constructor definition, parent is the class.
35- if ( typeChecker . getRootSymbols ( symbol ) . some ( s => calledDeclaration . symbol === s || calledDeclaration . symbol . parent === s ) ||
35+ if ( typeChecker . getRootSymbols ( symbol ) . some ( s => symbolMatchesSignature ( s , calledDeclaration ) ) ||
3636 // TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias
3737 symbol . declarations . some ( d => isVariableDeclaration ( d ) && ! ! d . initializer && isRequireCall ( d . initializer , /*checkArgumentIsStringLiteralLike*/ false ) ) ) {
3838 return [ sigInfo ] ;
@@ -93,6 +93,15 @@ namespace ts.GoToDefinition {
9393 return getDefinitionFromSymbol ( typeChecker , symbol , node ) ;
9494 }
9595
96+ /**
97+ * True if we should not add definitions for both the signature symbol and the definition symbol.
98+ * True for `const |f = |() => 0`, false for `function |f() {} const |g = f;`.
99+ */
100+ function symbolMatchesSignature ( s : Symbol , calledDeclaration : SignatureDeclaration ) {
101+ return s === calledDeclaration . symbol || s === calledDeclaration . symbol . parent ||
102+ isVariableDeclaration ( calledDeclaration . parent ) && s === calledDeclaration . parent . symbol
103+ }
104+
96105 export function getReferenceAtPosition ( sourceFile : SourceFile , position : number , program : Program ) : { fileName : string , file : SourceFile } | undefined {
97106 const referencePath = findReferenceInPosition ( sourceFile . referencedFiles , position ) ;
98107 if ( referencePath ) {
0 commit comments