(node, args, signature, relation, checkMode, reportErrors, containingMessageChain)
| 75713 | } |
| 75714 | } |
| 75715 | function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) { |
| 75716 | var errorOutputContainer = { errors: undefined, skipLogging: true }; |
| 75717 | if (ts.isJsxOpeningLikeElement(node)) { |
| 75718 | if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { |
| 75719 | ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); |
| 75720 | return errorOutputContainer.errors || ts.emptyArray; |
| 75721 | } |
| 75722 | return undefined; |
| 75723 | } |
| 75724 | var thisType = getThisTypeOfSignature(signature); |
| 75725 | if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { |
| 75726 | // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType |
| 75727 | // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. |
| 75728 | // If the expression is a new expression, then the check is skipped. |
| 75729 | var thisArgumentNode = getThisArgumentOfCall(node); |
| 75730 | var thisArgumentType = getThisArgumentType(thisArgumentNode); |
| 75731 | var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; |
| 75732 | var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; |
| 75733 | if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { |
| 75734 | ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); |
| 75735 | return errorOutputContainer.errors || ts.emptyArray; |
| 75736 | } |
| 75737 | } |
| 75738 | var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; |
| 75739 | var restType = getNonArrayRestType(signature); |
| 75740 | var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; |
| 75741 | for (var i = 0; i < argCount; i++) { |
| 75742 | var arg = args[i]; |
| 75743 | if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { |
| 75744 | var paramType = getTypeAtPosition(signature, i); |
| 75745 | var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); |
| 75746 | // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), |
| 75747 | // we obtain the regular type of any object literal arguments because we may not have inferred complete |
| 75748 | // parameter types yet and therefore excess property checks may yield false positives (see #17041). |
| 75749 | var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; |
| 75750 | if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { |
| 75751 | ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); |
| 75752 | maybeAddMissingAwaitInfo(arg, checkArgType, paramType); |
| 75753 | return errorOutputContainer.errors || ts.emptyArray; |
| 75754 | } |
| 75755 | } |
| 75756 | } |
| 75757 | if (restType) { |
| 75758 | var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, /*context*/ undefined, checkMode); |
| 75759 | var restArgCount = args.length - argCount; |
| 75760 | var errorNode = !reportErrors ? undefined : |
| 75761 | restArgCount === 0 ? node : |
| 75762 | restArgCount === 1 ? args[argCount] : |
| 75763 | ts.setTextRangePosEnd(createSyntheticExpression(node, spreadType), args[argCount].pos, args[args.length - 1].end); |
| 75764 | if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { |
| 75765 | ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); |
| 75766 | maybeAddMissingAwaitInfo(errorNode, spreadType, restType); |
| 75767 | return errorOutputContainer.errors || ts.emptyArray; |
| 75768 | } |
| 75769 | } |
| 75770 | return undefined; |
| 75771 | function maybeAddMissingAwaitInfo(errorNode, source, target) { |
| 75772 | if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) { |
no test coverage detected
searching dependent graphs…