@@ -2671,11 +2671,6 @@ namespace ts {
26712671 // Handle exports.p = expr or this.p = expr or className.prototype.method = expr
26722672 return links.type = checkExpressionCached((<BinaryExpression>declaration.parent).right);
26732673 }
2674- else {
2675- // Declaration for className.prototype in inferred JS class
2676- const type = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined);
2677- return links.type = type;
2678- }
26792674 }
26802675 // Handle variable, parameter or property
26812676 if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
@@ -6908,7 +6903,7 @@ namespace ts {
69086903 .expression as PropertyAccessExpression) // x.prototype
69096904 .expression; // x
69106905 const classSymbol = checkExpression(className).symbol;
6911- if (classSymbol.members) {
6906+ if (classSymbol && classSymbol .members) {
69126907 return createAnonymousType(undefined, classSymbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
69136908 }
69146909 }
@@ -9635,6 +9630,14 @@ namespace ts {
96359630 return links.resolvedSignature;
96369631 }
96379632
9633+ function getInferredClassType(symbol: Symbol) {
9634+ const links = getSymbolLinks(symbol);
9635+ if (!links.inferredClassType) {
9636+ links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
9637+ }
9638+ return links.inferredClassType;
9639+ }
9640+
96389641 /**
96399642 * Syntactically and semantically checks a call or new expression.
96409643 * @param node The call/new expression to be checked.
@@ -9661,7 +9664,7 @@ namespace ts {
96619664 // in a JS file
96629665 const funcSymbol = checkExpression(node.expression).symbol;
96639666 if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) {
9664- return createAnonymousType(undefined, funcSymbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined );
9667+ return getInferredClassType( funcSymbol);
96659668 }
96669669 else if (compilerOptions.noImplicitAny) {
96679670 error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
0 commit comments