fix(37194): fix crash on go to the definition in variable assignment (#37253)
This commit is contained in:
parent
48e1745d6d
commit
c8e43d878f
|
@ -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);
|
||||
}
|
||||
|
|
12
tests/cases/fourslash/goToDefinitionVariableAssignment.ts
Normal file
12
tests/cases/fourslash/goToDefinitionVariableAssignment.ts
Normal file
|
@ -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
tests/cases/fourslash/goToDefinitionVariableAssignment1.ts
Normal file
11
tests/cases/fourslash/goToDefinitionVariableAssignment1.ts
Normal file
|
@ -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
tests/cases/fourslash/goToDefinitionVariableAssignment2.ts
Normal file
10
tests/cases/fourslash/goToDefinitionVariableAssignment2.ts
Normal file
|
@ -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"]);
|
|
@ -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"]);
|
Loading…
Reference in a new issue