Skip to content

Commit

Permalink
Preserve instantiated substitution types for type variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Aug 22, 2022
1 parent a4a9ede commit e73d268
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17418,9 +17418,10 @@ namespace ts {
// A substitution type originates in the true branch of a conditional type and can be resolved
// to just the base type in the same cases as the conditional type resolves to its true branch
// (because the base type is then known to satisfy the constraint).
if (newConstraint.flags & TypeFlags.AnyOrUnknown ||
if (!(newBaseType.flags & TypeFlags.TypeVariable) && (
newConstraint.flags & TypeFlags.AnyOrUnknown ||
!isGenericType(newBaseType) && !isGenericType(newConstraint) ||
isTypeAssignableTo(getRestrictiveInstantiation(newBaseType), getRestrictiveInstantiation(newConstraint))) {
isTypeAssignableTo(getRestrictiveInstantiation(newBaseType), getRestrictiveInstantiation(newConstraint)))) {
return newBaseType;
}
return getSubstitutionType(newBaseType, newConstraint);
Expand Down

0 comments on commit e73d268

Please sign in to comment.