@@ -7917,16 +7917,25 @@ namespace ts {
79177917 return binarySearch(types, type, getTypeId, compareValues) >= 0;
79187918 }
79197919
7920- // Return true if the given intersection type contains (a) more than one unit type or (b) an object
7921- // type and a nullable type (null or undefined).
7920+ // Return true if the given intersection type contains
7921+ // more than one unit type or,
7922+ // an object type and a nullable type (null or undefined), or
7923+ // a string-like type and a non-string-like primitive type, or
7924+ // a number-like type and a non-number-like primitive type, or
7925+ // a symbol-like type and a non-symbol-like primitive type, or
7926+ // a void-like type and a non-void-like primitive type.
79227927 function isEmptyIntersectionType(type: IntersectionType) {
79237928 let combined: TypeFlags = 0;
79247929 for (const t of type.types) {
79257930 if (t.flags & TypeFlags.Unit && combined & TypeFlags.Unit) {
79267931 return true;
79277932 }
79287933 combined |= t.flags;
7929- if (combined & TypeFlags.Nullable && combined & (TypeFlags.Object | TypeFlags.NonPrimitive)) {
7934+ if (combined & TypeFlags.Nullable && combined & (TypeFlags.Object | TypeFlags.NonPrimitive) ||
7935+ combined & TypeFlags.StringLike && combined & (TypeFlags.Primitive & ~TypeFlags.StringLike) ||
7936+ combined & TypeFlags.NumberLike && combined & (TypeFlags.Primitive & ~TypeFlags.NumberLike) ||
7937+ combined & TypeFlags.ESSymbolLike && combined & (TypeFlags.Primitive & ~TypeFlags.ESSymbolLike) ||
7938+ combined & TypeFlags.VoidLike && combined & (TypeFlags.Primitive & ~TypeFlags.VoidLike)) {
79307939 return true;
79317940 }
79327941 }
0 commit comments