Skip to content

Commit c8e43d8

Browse files
authored
fix(37194): fix crash on go to the definition in variable assignment (#37253)
1 parent 48e1745 commit c8e43d8

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

src/services/goToDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ namespace ts.GoToDefinition {
252252
function getConstructSignatureDefinition(): DefinitionInfo[] | undefined {
253253
// Applicable only if we are in a new expression, or we are on a constructor declaration
254254
// and in either case the symbol has a construct signature definition, i.e. class
255-
if (symbol.flags & SymbolFlags.Class && !(symbol.flags & SymbolFlags.Function) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
255+
if (symbol.flags & SymbolFlags.Class && !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Variable)) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
256256
const cls = find(filteredDeclarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration");
257257
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
258258
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
// @filename: foo.js
6+
////const Bar;
7+
////const /*def1*/Foo = /*def2*/Bar = function () {}
8+
////Foo.prototype.bar = function() {}
9+
////new [|Foo/*ref*/|]();
10+
11+
goTo.file("foo.js");
12+
verify.goToDefinition("ref", ["def1", "def2"]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
// @filename: foo.js
6+
////const /*def1*/Foo = module./*def2*/exports = function () {}
7+
////Foo.prototype.bar = function() {}
8+
////new [|Foo/*ref*/|]();
9+
10+
goTo.file("foo.js");
11+
verify.goToDefinition("ref", ["def1", "def2"]);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: foo.ts
4+
////const Bar;
5+
////const /*def1*/Foo = /*def2*/Bar = function () {}
6+
////Foo.prototype.bar = function() {}
7+
////new [|Foo/*ref*/|]();
8+
9+
goTo.file("foo.ts");
10+
verify.goToDefinition("ref", ["def1", "def2"]);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: foo.ts
4+
////const /*def1*/Foo = module./*def2*/exports = function () {}
5+
////Foo.prototype.bar = function() {}
6+
////new [|Foo/*ref*/|]();
7+
8+
goTo.file("foo.ts");
9+
verify.goToDefinition("ref", ["def1", "def2"]);

0 commit comments

Comments
 (0)