Make boolean assignable to union types containing both true and false

This commit is contained in:
Anders Hejlsberg 2016-06-24 21:12:44 -07:00
parent 770f42377d
commit e900ebf856

View file

@ -6026,6 +6026,9 @@ namespace ts {
if (result = typeRelatedToSomeType(source, <UnionType>target, reportErrors && !(source.flags & TypeFlags.Primitive))) {
return result;
}
if (source === booleanType && contains((<UnionType>target).types, trueType) && contains((<UnionType>target).types, falseType)) {
return Ternary.True;
}
}
}