fix(37194): fix crash on go to the definition in variable assignment (#37253)

This commit is contained in:
Alexander T 2020-03-18 01:16:28 +02:00 committed by GitHub
parent 48e1745d6d
commit c8e43d878f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 1 deletions

View file

@ -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);
}

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

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

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

View file

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