Fixes #26122 - erroneous "TS2350" for js constructors called with incorrect parameters (#26124)

* Fixes #26122.

When `resolveCall` does not resolve in `resolveNewExpression`, the error should only be thrown if there is a *defined* signature that is not-void.

* Fix other baselines to remove erroneous TS2350.
This commit is contained in:
James Keane
2018-08-01 16:40:55 -04:00
committed by Nathan Shively-Sanders
parent a5a26ec939
commit 50f442f9ff
10 changed files with 55 additions and 25 deletions

View File

@@ -19592,7 +19592,7 @@ namespace ts {
const callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call);
if (callSignatures.length) {
const signature = resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp);
if (!isJavaScriptConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
if (signature.declaration && !isJavaScriptConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
}
if (getThisTypeOfSignature(signature) === voidType) {