mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Reduce void | undefined only in conjunction with subtype reduction
This commit is contained in:
@@ -13361,7 +13361,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeRedundantLiteralTypes(types: Type[], includes: TypeFlags) {
|
||||
function removeRedundantLiteralTypes(types: Type[], includes: TypeFlags, reduceVoidUndefined: boolean) {
|
||||
let i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
@@ -13372,7 +13372,7 @@ namespace ts {
|
||||
flags & TypeFlags.NumberLiteral && includes & TypeFlags.Number ||
|
||||
flags & TypeFlags.BigIntLiteral && includes & TypeFlags.BigInt ||
|
||||
flags & TypeFlags.UniqueESSymbol && includes & TypeFlags.ESSymbol ||
|
||||
flags & TypeFlags.Undefined && includes & TypeFlags.Void ||
|
||||
reduceVoidUndefined && flags & TypeFlags.Undefined && includes & TypeFlags.Void ||
|
||||
isFreshLiteralType(t) && containsType(types, (<LiteralType>t).regularType);
|
||||
if (remove) {
|
||||
orderedRemoveItemAt(types, i);
|
||||
@@ -13440,7 +13440,7 @@ namespace ts {
|
||||
}
|
||||
if (unionReduction & (UnionReduction.Literal | UnionReduction.Subtype)) {
|
||||
if (includes & (TypeFlags.Literal | TypeFlags.UniqueESSymbol) || includes & TypeFlags.Void && includes & TypeFlags.Undefined) {
|
||||
removeRedundantLiteralTypes(typeSet, includes);
|
||||
removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & UnionReduction.Subtype));
|
||||
}
|
||||
if (includes & TypeFlags.StringLiteral && includes & TypeFlags.TemplateLiteral) {
|
||||
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
|
||||
|
||||
Reference in New Issue
Block a user