This commit is contained in:
Anders Hejlsberg 2018-04-28 08:24:41 -07:00
parent e80b47da9e
commit 5a7eb1cbc8

View File

@ -8250,7 +8250,7 @@ namespace ts {
return includes;
}
function removeRedundantPrimtiveTypes(types: Type[], includes: TypeFlags) {
function removeRedundantPrimitiveTypes(types: Type[], includes: TypeFlags) {
let i = types.length;
while (i > 0) {
i--;
@ -8264,6 +8264,7 @@ namespace ts {
}
}
}
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
@ -8289,7 +8290,7 @@ namespace ts {
if (includes & TypeFlags.String && includes & TypeFlags.StringLiteral ||
includes & TypeFlags.Number && includes & TypeFlags.NumberLiteral ||
includes & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol) {
removeRedundantPrimtiveTypes(typeSet, includes);
removeRedundantPrimitiveTypes(typeSet, includes);
}
if (includes & TypeFlags.EmptyObject && !(includes & TypeFlags.Object)) {
typeSet.push(emptyObjectType);