From 7740822d02d8072f6360090ab10a953775fbe1a3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 21 Aug 2018 15:45:29 -0700 Subject: [PATCH] Simplify or get constraint in distributive conditional type, but not both --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d2b0187eb..8f043d51cd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6921,7 +6921,8 @@ namespace ts { // over the conditional type and possibly reduced. For example, 'T extends undefined ? never : T' // removes 'undefined' from T. if (type.root.isDistributive) { - const constraint = getConstraintOfType(getSimplifiedType(type.checkType)); + const simplified = getSimplifiedType(type.checkType); + const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint) { const mapper = makeUnaryTypeMapper(type.root.checkType, constraint); const instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper));