Avoid the class declaration not found assert when the new expression doesnt contain construct signature

This commit is contained in:
Sheetal Nandi 2018-02-07 13:30:58 -08:00
parent 35450d3451
commit dab0dbe6f0
2 changed files with 9 additions and 3 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);
}

View File

@ -5,6 +5,12 @@
////let I: {
//// /*constructSignature*/new(): C2;
////};
////let C = new [|/*invokeExpression*/I|]();
////new [|/*invokeExpression1*/I|]();
////let /*symbolDeclaration*/I2: {
////};
////new [|/*invokeExpression2*/I2|]();
verify.goToDefinition("invokeExpression", "constructSignature");
verify.goToDefinition({
invokeExpression1: "constructSignature",
invokeExpression2: "symbolDeclaration"
});