@@ -233,20 +233,23 @@ namespace ts.GoToDefinition {
233
233
}
234
234
235
235
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 ) ) ;
237
240
238
241
function getConstructSignatureDefinition ( ) : DefinitionInfo [ ] | undefined {
239
242
// Applicable only if we are in a new expression, or we are on a constructor declaration
240
243
// and in either case the symbol has a construct signature definition, i.e. class
241
244
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" ) ;
243
246
return getSignatureDefinition ( cls . members , /*selectConstructors*/ true ) ;
244
247
}
245
248
}
246
249
247
250
function getCallSignatureDefinition ( ) : DefinitionInfo [ ] | undefined {
248
251
return isCallOrNewExpressionTarget ( node ) || isNameOfFunctionDeclaration ( node )
249
- ? getSignatureDefinition ( symbol . declarations , /*selectConstructors*/ false )
252
+ ? getSignatureDefinition ( filteredDeclarations , /*selectConstructors*/ false )
250
253
: undefined ;
251
254
}
252
255
0 commit comments