Skip to content

Commit

Permalink
Reuse existing type instantiations
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed May 11, 2019
1 parent 33c7e7f commit bb9c5c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Expand Up @@ -10379,7 +10379,7 @@ namespace ts {
// Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`.
if (root.falseType.flags & TypeFlags.Never && getActualTypeVariable(root.trueType) === getActualTypeVariable(root.checkType)) {
if (checkType.flags & TypeFlags.Any || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true
return instantiateType(root.trueType, mapper);
return checkType;
}
else if (isIntersectionEmpty(checkType, extendsType)) { // Always false
return neverType;
Expand All @@ -10390,7 +10390,7 @@ namespace ts {
return neverType;
}
else if (checkType.flags & TypeFlags.Any || isIntersectionEmpty(checkType, extendsType)) { // Always false
return instantiateType(root.falseType, mapper);
return checkType;
}
}
const checkTypeInstantiable = maybeTypeOfKind(checkType, TypeFlags.Instantiable | TypeFlags.GenericMappedType);
Expand Down

0 comments on commit bb9c5c9

Please sign in to comment.