@@ -9784,31 +9784,29 @@ namespace ts {
9784
9784
if (checkType === wildcardType || extendsType === wildcardType) {
9785
9785
return wildcardType;
9786
9786
}
9787
- // If this is a distributive conditional type and the check type is generic we need to defer
9788
- // resolution of the conditional type such that a later instantiation will properly distribute
9789
- // over union types.
9790
- const isDeferred = root.isDistributive && maybeTypeOfKind(checkType, TypeFlags.Instantiable);
9787
+ const checkTypeInstantiable = maybeTypeOfKind(checkType, TypeFlags.Instantiable);
9791
9788
let combinedMapper: TypeMapper | undefined;
9792
9789
if (root.inferTypeParameters) {
9793
9790
const context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, InferenceFlags.None);
9794
- if (!isDeferred ) {
9791
+ if (!checkTypeInstantiable ) {
9795
9792
// We don't want inferences from constraints as they may cause us to eagerly resolve the
9796
9793
// conditional type instead of deferring resolution. Also, we always want strict function
9797
9794
// types rules (i.e. proper contravariance) for inferences.
9798
9795
inferTypes(context.inferences, checkType, extendsType, InferencePriority.NoConstraints | InferencePriority.AlwaysStrict);
9799
9796
}
9800
9797
combinedMapper = combineTypeMappers(mapper, context);
9801
9798
}
9802
- if (!isDeferred) {
9803
- if (extendsType.flags & TypeFlags.AnyOrUnknown) {
9799
+ // Instantiate the extends type including inferences for 'infer T' type parameters
9800
+ const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
9801
+ // We attempt to resolve the conditional type only when the check and extends types are non-generic
9802
+ if (!checkTypeInstantiable && !maybeTypeOfKind(inferredExtendsType, TypeFlags.Instantiable)) {
9803
+ if (inferredExtendsType.flags & TypeFlags.AnyOrUnknown) {
9804
9804
return instantiateType(root.trueType, mapper);
9805
9805
}
9806
9806
// Return union of trueType and falseType for 'any' since it matches anything
9807
9807
if (checkType.flags & TypeFlags.Any) {
9808
9808
return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]);
9809
9809
}
9810
- // Instantiate the extends type including inferences for 'infer T' type parameters
9811
- const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
9812
9810
// Return falseType for a definitely false extends check. We check an instantations of the two
9813
9811
// types with type parameters mapped to the wildcard type, the most permissive instantiations
9814
9812
// possible (the wildcard type is assignable to and from all types). If those are not related,
0 commit comments