Look at simplified types when checking distributive conditional constraints (#23884)

This commit is contained in:
Wesley Wigham
2018-05-04 14:35:39 -07:00
committed by GitHub
parent df9e2621d2
commit 618da24d6a
5 changed files with 48 additions and 2 deletions

View File

@@ -6505,9 +6505,9 @@ 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(type.checkType);
const constraint = getConstraintOfType(getSimplifiedType(type.checkType));
if (constraint) {
const mapper = createTypeMapper([<TypeParameter>type.root.checkType], [constraint]);
const mapper = makeUnaryTypeMapper(type.root.checkType, constraint);
const instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper));
if (!(instantiated.flags & TypeFlags.Never)) {
return instantiated;