Skip to content

Commit 13e1ccd

Browse files
authored
goto-def should treat constructor functions as functions (#33109)
* goto-def:special handling for constructor functions * Just treat constructor functions like functions * Even simpler fallback
1 parent 4fc12d7 commit 13e1ccd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/services/goToDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ namespace ts.GoToDefinition {
241241
function getConstructSignatureDefinition(): DefinitionInfo[] | undefined {
242242
// Applicable only if we are in a new expression, or we are on a constructor declaration
243243
// and in either case the symbol has a construct signature definition, i.e. class
244-
if (symbol.flags & SymbolFlags.Class && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
244+
if (symbol.flags & SymbolFlags.Class && !(symbol.flags & SymbolFlags.Function) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
245245
const cls = find(filteredDeclarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration");
246246
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
247247
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @noEmit: true
5+
// @filename: gotoDefinitionConstructorFunction.js
6+
//// function /*end*/StringStreamm() {
7+
//// }
8+
//// StringStreamm.prototype = {
9+
//// };
10+
////
11+
//// function runMode () {
12+
//// new [|/*start*/StringStreamm|]()
13+
//// };
14+
15+
verify.goToDefinition('start', 'end')

0 commit comments

Comments
 (0)