You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+3-29Lines changed: 3 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -14784,11 +14784,11 @@ namespace ts {
14784
14784
includes |= TypeFlags.IncludesNonWideningType;
14785
14785
if (flags & TypeFlags.Undefined) {
14786
14786
if (!undefinedVariant) undefinedVariant = type;
14787
-
else undefinedVariant = undefinedType; // multiple of the missing, optional, or base undefined types combine to just normal undefined
14787
+
else if (undefinedVariant !== type) undefinedVariant = undefinedType; // multiple of the missing, optional, or base undefined types combine to just normal undefined
14788
14788
}
14789
14789
else if (flags & TypeFlags.Null) {
14790
14790
if (!nullVariant) nullVariant = type;
14791
-
else nullVariant = nullType;
14791
+
else if (nullVariant !== type) nullVariant = nullType;
14792
14792
}
14793
14793
}
14794
14794
}
@@ -25185,40 +25185,14 @@ namespace ts {
25185
25185
return result;
25186
25186
}
25187
25187
25188
-
/**
25189
-
* This function preserves the non-strict mode behavior of `undefined` and `null` evaporating on contact with a union
25190
-
* It uses `filterType` rather than `getTypeWithFacts` because `getTypeWithFacts` would consider generic constraints, which
25191
-
* the old non-strict union-creation behavior never did.
25192
-
*/
25193
-
function filterNullAndUndefinedFromUnionIfNotStrict(type: Type) {
25194
-
if (strictNullChecks(reference)) {
25195
-
return type;
25196
-
}
25197
-
if (!(type.flags & TypeFlags.Union)) {
25198
-
return type;
25199
-
}
25200
-
let containedNull: Type | undefined;
25201
-
const filtered = filterType(type, t => {
25202
-
if (t.flags & TypeFlags.Null) {
25203
-
containedNull = t;
25204
-
}
25205
-
return !(t.flags & TypeFlags.Nullable);
25206
-
});
25207
-
if (!(filtered.flags & TypeFlags.Never)) {
25208
-
return filtered;
25209
-
}
25210
-
// only null/undefined union members - if both are present, historically, this makes the union evaluate to `null`
25211
-
return containedNull || type;
25212
-
}
25213
-
25214
25188
// At flow control branch or loop junctions, if the type along every antecedent code path
25215
25189
// is an evolving array type, we construct a combined evolving array type. Otherwise we
25216
25190
// finalize all evolving array types.
25217
25191
function getUnionOrEvolvingArrayType(types: Type[], subtypeReduction: UnionReduction) {
0 commit comments