(signature, contextualSignature, inferenceContext, compareTypes)
| 75434 | } |
| 75435 | // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) |
| 75436 | function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { |
| 75437 | var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); |
| 75438 | // We clone the inferenceContext to avoid fixing. For example, when the source signature is <T>(x: T) => T[] and |
| 75439 | // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') |
| 75440 | // for T but leave it possible to later infer '[any]' back to A. |
| 75441 | var restType = getEffectiveRestType(contextualSignature); |
| 75442 | var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); |
| 75443 | var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; |
| 75444 | applyToParameterTypes(sourceSignature, signature, function (source, target) { |
| 75445 | // Type parameters from outer context referenced by source type are fixed by instantiation of the source type |
| 75446 | inferTypes(context.inferences, source, target); |
| 75447 | }); |
| 75448 | if (!inferenceContext) { |
| 75449 | applyToReturnTypes(contextualSignature, signature, function (source, target) { |
| 75450 | inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); |
| 75451 | }); |
| 75452 | } |
| 75453 | return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); |
| 75454 | } |
| 75455 | function inferJsxTypeArguments(node, signature, checkMode, context) { |
| 75456 | var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); |
| 75457 | var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode); |
no test coverage detected