Filter nullables after lifting union over spread

Previously, null/undefined were removed upfront, which is incorrect. Now
nullable types are removed with other non-primitives after union is
lifted over spread. This produces unions, which are larger, but more correct.
This commit is contained in:
Nathan Shively-Sanders 2017-06-06 14:11:01 -07:00
parent ea830d4fad
commit 93465bdae2

View File

@ -7632,11 +7632,9 @@ namespace ts {
if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) {
return anyType;
}
left = filterType(left, t => !(t.flags & TypeFlags.Nullable));
if (left.flags & TypeFlags.Never) {
return right;
}
right = filterType(right, t => !(t.flags & TypeFlags.Nullable));
if (right.flags & TypeFlags.Never) {
return left;
}