Skip to content

Commit e73d268

Browse files
committed
Preserve instantiated substitution types for type variables
1 parent a4a9ede commit e73d268

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compiler/checker.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -17418,9 +17418,10 @@ namespace ts {
1741817418
// A substitution type originates in the true branch of a conditional type and can be resolved
1741917419
// to just the base type in the same cases as the conditional type resolves to its true branch
1742017420
// (because the base type is then known to satisfy the constraint).
17421-
if (newConstraint.flags & TypeFlags.AnyOrUnknown ||
17421+
if (!(newBaseType.flags & TypeFlags.TypeVariable) && (
17422+
newConstraint.flags & TypeFlags.AnyOrUnknown ||
1742217423
!isGenericType(newBaseType) && !isGenericType(newConstraint) ||
17423-
isTypeAssignableTo(getRestrictiveInstantiation(newBaseType), getRestrictiveInstantiation(newConstraint))) {
17424+
isTypeAssignableTo(getRestrictiveInstantiation(newBaseType), getRestrictiveInstantiation(newConstraint)))) {
1742417425
return newBaseType;
1742517426
}
1742617427
return getSubstitutionType(newBaseType, newConstraint);

0 commit comments

Comments
 (0)