@@ -233,20 +233,23 @@ namespace ts.GoToDefinition {
233233 }
234234
235235 function getDefinitionFromSymbol ( typeChecker : TypeChecker , symbol : Symbol , node : Node ) : DefinitionInfo [ ] | undefined {
236- return getConstructSignatureDefinition ( ) || getCallSignatureDefinition ( ) || map ( symbol . declarations , declaration => createDefinitionInfo ( declaration , typeChecker , symbol , node ) ) ;
236+ // There are cases when you extend a function by adding properties to it afterwards,
237+ // we want to strip those extra properties
238+ const filteredDeclarations = filter ( symbol . declarations , d => ! isAssignmentDeclaration ( d ) || d === symbol . valueDeclaration ) || undefined ;
239+ return getConstructSignatureDefinition ( ) || getCallSignatureDefinition ( ) || map ( filteredDeclarations , declaration => createDefinitionInfo ( declaration , typeChecker , symbol , node ) ) ;
237240
238241 function getConstructSignatureDefinition ( ) : DefinitionInfo [ ] | undefined {
239242 // Applicable only if we are in a new expression, or we are on a constructor declaration
240243 // and in either case the symbol has a construct signature definition, i.e. class
241244 if ( symbol . flags & SymbolFlags . Class && ( isNewExpressionTarget ( node ) || node . kind === SyntaxKind . ConstructorKeyword ) ) {
242- const cls = find ( symbol . declarations , isClassLike ) || Debug . fail ( "Expected declaration to have at least one class-like declaration" ) ;
245+ const cls = find ( filteredDeclarations , isClassLike ) || Debug . fail ( "Expected declaration to have at least one class-like declaration" ) ;
243246 return getSignatureDefinition ( cls . members , /*selectConstructors*/ true ) ;
244247 }
245248 }
246249
247250 function getCallSignatureDefinition ( ) : DefinitionInfo [ ] | undefined {
248251 return isCallOrNewExpressionTarget ( node ) || isNameOfFunctionDeclaration ( node )
249- ? getSignatureDefinition ( symbol . declarations , /*selectConstructors*/ false )
252+ ? getSignatureDefinition ( filteredDeclarations , /*selectConstructors*/ false )
250253 : undefined ;
251254 }
252255
0 commit comments