@@ -15638,14 +15638,16 @@ namespace ts {
15638
15638
return result;
15639
15639
}
15640
15640
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
+
15641
15647
function getTypeFromConditionalTypeNode(node: ConditionalTypeNode): Type {
15642
15648
const links = getNodeLinks(node);
15643
15649
if (!links.resolvedType) {
15644
15650
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));
15649
15651
const aliasSymbol = getAliasSymbolForTypeNode(node);
15650
15652
const aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
15651
15653
const allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
@@ -15654,8 +15656,7 @@ namespace ts {
15654
15656
node,
15655
15657
checkType,
15656
15658
extendsType: getTypeFromTypeNode(node.extendsType),
15657
- isDistributive,
15658
- isDistributionDependent,
15659
+ isDistributive: !!(checkType.flags & TypeFlags.TypeParameter),
15659
15660
inferTypeParameters: getInferTypeParameters(node),
15660
15661
outerTypeParameters,
15661
15662
instantiations: undefined,
@@ -19032,7 +19033,7 @@ namespace ts {
19032
19033
// We check for a relationship to a conditional type target only when the conditional type has no
19033
19034
// 'infer' positions and is not distributive or is distributive but doesn't reference the check type
19034
19035
// parameter in either of the result types.
19035
- if (!c.root.inferTypeParameters && !c.root.isDistributionDependent ) {
19036
+ if (!c.root.inferTypeParameters && !isDistributionDependent( c.root) ) {
19036
19037
// Check if the conditional is always true or always false but still deferred for distribution purposes.
19037
19038
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
19038
19039
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
0 commit comments