@@ -16024,15 +16024,9 @@ namespace ts {
16024
16024
}
16025
16025
else if (target.flags & TypeFlags.Conditional) {
16026
16026
const c = target as ConditionalType;
16027
- let skipFalse = false;
16028
- let skipTrue = false;
16029
16027
// Check if the conditional is always true or always false but still deferred for distribution purposes
16030
- if (!isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType))) {
16031
- skipTrue = true;
16032
- }
16033
- else if (isConditionalTypeAlwaysTrueDisregardingInferTypes(c)) {
16034
- skipFalse = true;
16035
- }
16028
+ const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
16029
+ const skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c);
16036
16030
16037
16031
// Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself,
16038
16032
// this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when
@@ -16048,9 +16042,9 @@ namespace ts {
16048
16042
16049
16043
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
16050
16044
let localResult: Ternary | undefined;
16051
- if (skipTrue || (localResult = isRelatedTo(source, instantiateType(getTrueTypeFromConditionalType(c) , distributionMapper), /*reportErrors*/ false))) {
16045
+ if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(c.root.trueType , distributionMapper) : getTrueTypeFromConditionalType(c ), /*reportErrors*/ false))) {
16052
16046
if (!skipFalse) {
16053
- localResult = (localResult || Ternary.Maybe) & isRelatedTo(source, instantiateType(getFalseTypeFromConditionalType(c) , distributionMapper), /*reportErrors*/ false);
16047
+ localResult = (localResult || Ternary.Maybe) & isRelatedTo(source, distributionMapper ? instantiateType(c.root.falseType , distributionMapper) : getFalseTypeFromConditionalType(c ), /*reportErrors*/ false);
16054
16048
}
16055
16049
}
16056
16050
if (localResult) {
0 commit comments