Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/goToDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/goToDefinitionVariableAssignment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />

// @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"]);
11 changes: 11 additions & 0 deletions tests/cases/fourslash/goToDefinitionVariableAssignment1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />

// @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"]);
10 changes: 10 additions & 0 deletions tests/cases/fourslash/goToDefinitionVariableAssignment2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />

// @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"]);
9 changes: 9 additions & 0 deletions tests/cases/fourslash/goToDefinitionVariableAssignment3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />

// @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"]);