diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index e514ca01e7947..22d28efd2f4e0 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -241,7 +241,7 @@ namespace ts.GoToDefinition { function getConstructSignatureDefinition(): DefinitionInfo[] | undefined { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & SymbolFlags.Class && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) { + if (symbol.flags & SymbolFlags.Class && !(symbol.flags & SymbolFlags.Function) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) { const cls = find(filteredDeclarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } diff --git a/tests/cases/fourslash/gotoDefinitionConstructorFunction.ts b/tests/cases/fourslash/gotoDefinitionConstructorFunction.ts new file mode 100644 index 0000000000000..aa149e70d7dc4 --- /dev/null +++ b/tests/cases/fourslash/gotoDefinitionConstructorFunction.ts @@ -0,0 +1,15 @@ +/// +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @filename: gotoDefinitionConstructorFunction.js +//// function /*end*/StringStreamm() { +//// } +//// StringStreamm.prototype = { +//// }; +//// +//// function runMode () { +//// new [|/*start*/StringStreamm|]() +//// }; + +verify.goToDefinition('start', 'end')