@@ -15638,14 +15638,16 @@ namespace ts {
1563815638 return result;
1563915639 }
1564015640
15641+ function isDistributionDependent(root: ConditionalRoot) {
15642+ return root.isDistributive && (
15643+ isTypeParameterPossiblyReferenced(root.checkType as TypeParameter, root.node.trueType) ||
15644+ isTypeParameterPossiblyReferenced(root.checkType as TypeParameter, root.node.falseType));
15645+ }
15646+
1564115647 function getTypeFromConditionalTypeNode(node: ConditionalTypeNode): Type {
1564215648 const links = getNodeLinks(node);
1564315649 if (!links.resolvedType) {
1564415650 const checkType = getTypeFromTypeNode(node.checkType);
15645- const isDistributive = !!(checkType.flags & TypeFlags.TypeParameter);
15646- const isDistributionDependent = isDistributive && (
15647- isTypeParameterPossiblyReferenced(checkType as TypeParameter, node.trueType) ||
15648- isTypeParameterPossiblyReferenced(checkType as TypeParameter, node.falseType));
1564915651 const aliasSymbol = getAliasSymbolForTypeNode(node);
1565015652 const aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
1565115653 const allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
@@ -15654,8 +15656,7 @@ namespace ts {
1565415656 node,
1565515657 checkType,
1565615658 extendsType: getTypeFromTypeNode(node.extendsType),
15657- isDistributive,
15658- isDistributionDependent,
15659+ isDistributive: !!(checkType.flags & TypeFlags.TypeParameter),
1565915660 inferTypeParameters: getInferTypeParameters(node),
1566015661 outerTypeParameters,
1566115662 instantiations: undefined,
@@ -19032,7 +19033,7 @@ namespace ts {
1903219033 // We check for a relationship to a conditional type target only when the conditional type has no
1903319034 // 'infer' positions and is not distributive or is distributive but doesn't reference the check type
1903419035 // parameter in either of the result types.
19035- if (!c.root.inferTypeParameters && !c.root.isDistributionDependent ) {
19036+ if (!c.root.inferTypeParameters && !isDistributionDependent( c.root) ) {
1903619037 // Check if the conditional is always true or always false but still deferred for distribution purposes.
1903719038 const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
1903819039 const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
0 commit comments