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:
Sheetal Nandi
2018-02-07 13:50:02 -08:00
committed by GitHub
2 changed files with 18 additions and 1 deletions

View File

@@ -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:

View File

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