diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 1f7e2ea0be9..fcad5eb10b0 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -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: diff --git a/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts b/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts new file mode 100644 index 00000000000..02a6dca9d52 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts @@ -0,0 +1,16 @@ +/// + +////class C2 { +////} +////let I: { +//// /*constructSignature*/new(): C2; +////}; +////new [|/*invokeExpression1*/I|](); +////let /*symbolDeclaration*/I2: { +////}; +////new [|/*invokeExpression2*/I2|](); + +verify.goToDefinition({ + invokeExpression1: "constructSignature", + invokeExpression2: "symbolDeclaration" +});