Skip to content

Commit 7740822

Browse files
committed
Simplify or get constraint in distributive conditional type, but not both
1 parent 7c2644a commit 7740822

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6921,7 +6921,8 @@ namespace ts {
69216921
// over the conditional type and possibly reduced. For example, 'T extends undefined ? never : T'
69226922
// removes 'undefined' from T.
69236923
if (type.root.isDistributive) {
6924-
const constraint = getConstraintOfType(getSimplifiedType(type.checkType));
6924+
const simplified = getSimplifiedType(type.checkType);
6925+
const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
69256926
if (constraint) {
69266927
const mapper = makeUnaryTypeMapper(type.root.checkType, constraint);
69276928
const instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper));

0 commit comments

Comments
 (0)