Skip to content

Commit bb9c5c9

Browse files
committed
Reuse existing type instantiations
1 parent 33c7e7f commit bb9c5c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10379,7 +10379,7 @@ namespace ts {
1037910379
// Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`.
1038010380
if (root.falseType.flags & TypeFlags.Never && getActualTypeVariable(root.trueType) === getActualTypeVariable(root.checkType)) {
1038110381
if (checkType.flags & TypeFlags.Any || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
10382-
return instantiateType(root.trueType, mapper);
10382+
return checkType;
1038310383
}
1038410384
else if (isIntersectionEmpty(checkType, extendsType)) { // Always false
1038510385
return neverType;
@@ -10390,7 +10390,7 @@ namespace ts {
1039010390
return neverType;
1039110391
}
1039210392
else if (checkType.flags & TypeFlags.Any || isIntersectionEmpty(checkType, extendsType)) { // Always false
10393-
return instantiateType(root.falseType, mapper);
10393+
return checkType;
1039410394
}
1039510395
}
1039610396
const checkTypeInstantiable = maybeTypeOfKind(checkType, TypeFlags.Instantiable | TypeFlags.GenericMappedType);

0 commit comments

Comments
 (0)