Add missing arity check on second inference pass (#29386)

This commit is contained in:
Wesley Wigham
2019-01-17 15:21:17 -08:00
committed by GitHub
parent 9bd23652ef
commit b6ae492009
6 changed files with 106 additions and 0 deletions

View File

@@ -20422,6 +20422,12 @@ namespace ts {
if (inferenceContext) {
const typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext);
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration));
// If the original signature has a generic rest type, instantiation may produce a
// signature with different arity and we need to perform another arity check.
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
candidateForArgumentArityError = checkCandidate;
continue;
}
}
if (!checkApplicableSignature(node, args, checkCandidate, relation, excludeArgument, /*reportErrors*/ false)) {
// Give preference to error candidates that have no rest parameters (as they are more specific)