@@ -15355,40 +15355,6 @@ namespace ts {
15355
15355
}
15356
15356
}
15357
15357
}
15358
- else if (target.flags & TypeFlags.Conditional) {
15359
- const c = target as ConditionalType;
15360
- let skipFalse = false;
15361
- let skipTrue = false;
15362
- // Check if the conditional is always true or always false but still deferred for distribution purposes
15363
- if (!isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType))) {
15364
- skipTrue = true;
15365
- }
15366
- else if (isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType))) {
15367
- skipFalse = true;
15368
- }
15369
- // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself,
15370
- // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when
15371
- // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`,
15372
- // to which `{x: string | number, y: string | number}` isn't assignable)
15373
- let distributionMapper: TypeMapper | undefined;
15374
- const checkVar = getActualTypeVariable(c.root.checkType);
15375
- if (c.root.isDistributive && checkVar.flags & TypeFlags.TypeParameter) {
15376
- const newParam = cloneTypeParameter(checkVar);
15377
- distributionMapper = createReplacementMapper(checkVar, newParam, c.mapper || identityMapper);
15378
- newParam.mapper = distributionMapper;
15379
- }
15380
- // TODO: Find a nice way to include potential conditional type breakdowns in error output, if those seems good (they usually don't)
15381
- let localResult: Ternary | undefined;
15382
- if (skipTrue || (localResult = isRelatedTo(source, instantiateType(getTrueTypeFromConditionalType(c), distributionMapper), /*reportErrors*/ false))) {
15383
- if (!skipFalse) {
15384
- localResult = (localResult || Ternary.Maybe) & isRelatedTo(source, instantiateType(getFalseTypeFromConditionalType(c), distributionMapper), /*reportErrors*/ false);
15385
- }
15386
- }
15387
- if (localResult) {
15388
- errorInfo = saveErrorInfo;
15389
- return localResult;
15390
- }
15391
- }
15392
15358
15393
15359
if (source.flags & TypeFlags.TypeVariable) {
15394
15360
if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) {
@@ -15444,9 +15410,8 @@ namespace ts {
15444
15410
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
15445
15411
mapper = ctx.mapper;
15446
15412
}
15447
- if (isRelatedTo(sourceExtends, (<ConditionalType>target).extendsType) &&
15448
- isRelatedTo((<ConditionalType>target).extendsType, sourceExtends) &&
15449
- (isRelatedTo((<ConditionalType>source).checkType, (<ConditionalType>target).checkType) || isRelatedTo((<ConditionalType>target).checkType, (<ConditionalType>source).checkType))) {
15413
+ if (isTypeIdenticalTo(sourceExtends, (<ConditionalType>target).extendsType) &&
15414
+ (isRelatedTo((<ConditionalType>source).checkType, (<ConditionalType>target).checkType) || isRelatedTo((<ConditionalType>target).checkType, (<ConditionalType>source).checkType))) {
15450
15415
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(<ConditionalType>source), mapper), getTrueTypeFromConditionalType(<ConditionalType>target), reportErrors)) {
15451
15416
result &= isRelatedTo(getFalseTypeFromConditionalType(<ConditionalType>source), getFalseTypeFromConditionalType(<ConditionalType>target), reportErrors);
15452
15417
}
0 commit comments