mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 17:27:54 -05:00
Merge pull request #21740 from Microsoft/gotoDefinition
Fix assert when goToDefinition, from location that is new expression target but not a class symbol
This commit is contained in:
@@ -191,7 +191,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 (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword && symbol.flags & SymbolFlags.Class) {
|
||||
if (symbol.flags & SymbolFlags.Class && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) {
|
||||
const cls = find(symbol.declarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration");
|
||||
return getSignatureDefinition(cls.members, /*selectConstructors*/ true);
|
||||
}
|
||||
@@ -217,6 +217,7 @@ namespace ts.GoToDefinition {
|
||||
function isSignatureDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case ts.SyntaxKind.Constructor:
|
||||
case ts.SyntaxKind.ConstructSignature:
|
||||
case ts.SyntaxKind.FunctionDeclaration:
|
||||
case ts.SyntaxKind.MethodDeclaration:
|
||||
case ts.SyntaxKind.MethodSignature:
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C2 {
|
||||
////}
|
||||
////let I: {
|
||||
//// /*constructSignature*/new(): C2;
|
||||
////};
|
||||
////new [|/*invokeExpression1*/I|]();
|
||||
////let /*symbolDeclaration*/I2: {
|
||||
////};
|
||||
////new [|/*invokeExpression2*/I2|]();
|
||||
|
||||
verify.goToDefinition({
|
||||
invokeExpression1: "constructSignature",
|
||||
invokeExpression2: "symbolDeclaration"
|
||||
});
|
||||
Reference in New Issue
Block a user