(inference, signature)
| 69126 | return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); |
| 69127 | } |
| 69128 | function getCovariantInference(inference, signature) { |
| 69129 | // Extract all object and array literal types and replace them with a single widened and normalized type. |
| 69130 | var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates); |
| 69131 | // We widen inferred literal types if |
| 69132 | // all inferences were made to top-level occurrences of the type parameter, and |
| 69133 | // the type parameter has no constraint or its constraint includes no primitive or literal types, and |
| 69134 | // the type parameter was fixed during inference or does not occur at top-level in the return type. |
| 69135 | var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); |
| 69136 | var widenLiteralTypes = !primitiveConstraint && inference.topLevel && |
| 69137 | (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); |
| 69138 | var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : |
| 69139 | widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : |
| 69140 | candidates; |
| 69141 | // If all inferences were made from a position that implies a combined result, infer a union type. |
| 69142 | // Otherwise, infer a common supertype. |
| 69143 | var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? |
| 69144 | getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : |
| 69145 | getCommonSupertype(baseCandidates); |
| 69146 | return getWidenedType(unwidenedType); |
| 69147 | } |
| 69148 | function getInferredType(context, index) { |
| 69149 | var inference = context.inferences[index]; |
| 69150 | if (!inference.inferredType) { |
no test coverage detected