You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (isTypeIdenticalTo(sourceExtends, (target as ConditionalType).extendsType) &&
19145
-
(isRelatedTo((source as ConditionalType).checkType, (target as ConditionalType).checkType, RecursionFlags.Both) || isRelatedTo((target as ConditionalType).checkType, (source as ConditionalType).checkType, RecursionFlags.Both))) {
19146
-
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source as ConditionalType), mapper), getTrueTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors)) {
19147
-
result &= isRelatedTo(getFalseTypeFromConditionalType(source as ConditionalType), getFalseTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors);
19148
-
}
19149
-
if (result) {
19150
-
resetErrorInfo(saveErrorInfo);
19151
-
return result;
19152
-
}
19139
+
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
19140
+
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
19141
+
// and Y1 is related to Y2.
19142
+
const sourceParams = (source as ConditionalType).root.inferTypeParameters;
19143
+
let sourceExtends = (source as ConditionalType).extendsType;
19144
+
let mapper: TypeMapper | undefined;
19145
+
if (sourceParams) {
19146
+
// If the source has infer type parameters, we instantiate them in the context of the target
if (isTypeIdenticalTo(sourceExtends, (target as ConditionalType).extendsType) &&
19153
+
(isRelatedTo((source as ConditionalType).checkType, (target as ConditionalType).checkType, RecursionFlags.Both) || isRelatedTo((target as ConditionalType).checkType, (source as ConditionalType).checkType, RecursionFlags.Both))) {
19154
+
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source as ConditionalType), mapper), getTrueTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors)) {
19155
+
result &= isRelatedTo(getFalseTypeFromConditionalType(source as ConditionalType), getFalseTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors);
19156
+
}
19157
+
if (result) {
19158
+
resetErrorInfo(saveErrorInfo);
19159
+
return result;
19153
19160
}
19154
19161
}
19155
19162
}
@@ -19165,18 +19172,13 @@ namespace ts {
19165
19172
}
19166
19173
}
19167
19174
19168
-
19169
-
// We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
19170
-
// on the comparison.
19171
-
if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
19172
-
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
19173
-
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
19174
-
const defaultConstraint = getDefaultConstraintOfConditionalType(source as ConditionalType);
19175
-
if (defaultConstraint) {
19176
-
if (result = isRelatedTo(defaultConstraint, target, RecursionFlags.Source, reportErrors)) {
19177
-
resetErrorInfo(saveErrorInfo);
19178
-
return result;
19179
-
}
19175
+
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
19176
+
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
19177
+
const defaultConstraint = getDefaultConstraintOfConditionalType(source as ConditionalType);
19178
+
if (defaultConstraint) {
19179
+
if (result = isRelatedTo(defaultConstraint, target, RecursionFlags.Source, reportErrors)) {
0 commit comments