diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 110c90f05d..daafc49057 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -252,7 +252,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 && !(symbol.flags & SymbolFlags.Function) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) { + if (symbol.flags & SymbolFlags.Class && !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Variable)) && (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/goToDefinitionVariableAssignment.ts b/tests/cases/fourslash/goToDefinitionVariableAssignment.ts new file mode 100644 index 0000000000..09d5f1126f --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionVariableAssignment.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @checkJs: true +// @filename: foo.js +////const Bar; +////const /*def1*/Foo = /*def2*/Bar = function () {} +////Foo.prototype.bar = function() {} +////new [|Foo/*ref*/|](); + +goTo.file("foo.js"); +verify.goToDefinition("ref", ["def1", "def2"]); diff --git a/tests/cases/fourslash/goToDefinitionVariableAssignment1.ts b/tests/cases/fourslash/goToDefinitionVariableAssignment1.ts new file mode 100644 index 0000000000..45e666cafa --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionVariableAssignment1.ts @@ -0,0 +1,11 @@ +/// + +// @allowJs: true +// @checkJs: true +// @filename: foo.js +////const /*def1*/Foo = module./*def2*/exports = function () {} +////Foo.prototype.bar = function() {} +////new [|Foo/*ref*/|](); + +goTo.file("foo.js"); +verify.goToDefinition("ref", ["def1", "def2"]); diff --git a/tests/cases/fourslash/goToDefinitionVariableAssignment2.ts b/tests/cases/fourslash/goToDefinitionVariableAssignment2.ts new file mode 100644 index 0000000000..d5474cda93 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionVariableAssignment2.ts @@ -0,0 +1,10 @@ +/// + +// @filename: foo.ts +////const Bar; +////const /*def1*/Foo = /*def2*/Bar = function () {} +////Foo.prototype.bar = function() {} +////new [|Foo/*ref*/|](); + +goTo.file("foo.ts"); +verify.goToDefinition("ref", ["def1", "def2"]); diff --git a/tests/cases/fourslash/goToDefinitionVariableAssignment3.ts b/tests/cases/fourslash/goToDefinitionVariableAssignment3.ts new file mode 100644 index 0000000000..85d6c43e72 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionVariableAssignment3.ts @@ -0,0 +1,9 @@ +/// + +// @filename: foo.ts +////const /*def1*/Foo = module./*def2*/exports = function () {} +////Foo.prototype.bar = function() {} +////new [|Foo/*ref*/|](); + +goTo.file("foo.ts"); +verify.goToDefinition("ref", ["def1", "def2"]);