(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma)
| 76240 | candidateForTypeArgumentError = oldCandidateForTypeArgumentError; |
| 76241 | } |
| 76242 | function chooseOverload(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma) { |
| 76243 | if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } |
| 76244 | candidatesForArgumentError = undefined; |
| 76245 | candidateForArgumentArityError = undefined; |
| 76246 | candidateForTypeArgumentError = undefined; |
| 76247 | if (isSingleNonGenericCandidate) { |
| 76248 | var candidate = candidates[0]; |
| 76249 | if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { |
| 76250 | return undefined; |
| 76251 | } |
| 76252 | if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { |
| 76253 | candidatesForArgumentError = [candidate]; |
| 76254 | return undefined; |
| 76255 | } |
| 76256 | return candidate; |
| 76257 | } |
| 76258 | for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { |
| 76259 | var candidate = candidates[candidateIndex]; |
| 76260 | if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { |
| 76261 | continue; |
| 76262 | } |
| 76263 | var checkCandidate = void 0; |
| 76264 | var inferenceContext = void 0; |
| 76265 | if (candidate.typeParameters) { |
| 76266 | var typeArgumentTypes = void 0; |
| 76267 | if (ts.some(typeArguments)) { |
| 76268 | typeArgumentTypes = checkTypeArguments(candidate, typeArguments, /*reportErrors*/ false); |
| 76269 | if (!typeArgumentTypes) { |
| 76270 | candidateForTypeArgumentError = candidate; |
| 76271 | continue; |
| 76272 | } |
| 76273 | } |
| 76274 | else { |
| 76275 | inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); |
| 76276 | typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); |
| 76277 | argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; |
| 76278 | } |
| 76279 | checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); |
| 76280 | // If the original signature has a generic rest type, instantiation may produce a |
| 76281 | // signature with different arity and we need to perform another arity check. |
| 76282 | if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { |
| 76283 | candidateForArgumentArityError = checkCandidate; |
| 76284 | continue; |
| 76285 | } |
| 76286 | } |
| 76287 | else { |
| 76288 | checkCandidate = candidate; |
| 76289 | } |
| 76290 | if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { |
| 76291 | // Give preference to error candidates that have no rest parameters (as they are more specific) |
| 76292 | (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate); |
| 76293 | continue; |
| 76294 | } |
| 76295 | if (argCheckMode) { |
| 76296 | // If one or more context sensitive arguments were excluded, we start including |
| 76297 | // them now (and keeping do so for any subsequent candidates) and perform a second |
| 76298 | // round of type inference and applicability checking for this particular candidate. |
| 76299 | argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; |
no test coverage detected
searching dependent graphs…