Skip to content

Commit 73802be

Browse files
committed
Undo extra subtype reduction in getWidenedType
1 parent 39383ca commit 73802be

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/compiler/checker.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -10551,11 +10551,7 @@ namespace ts {
1055110551
}
1055210552
if (type.flags & TypeFlags.Union) {
1055310553
const unionContext = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, (<UnionType>type).types);
10554-
const widenedTypes = sameMap((<UnionType>type).types, t => t.flags & TypeFlags.Nullable ? t : getWidenedTypeWithContext(t, unionContext));
10555-
// Widening an empty object literal transitions from a highly restrictive type to
10556-
// a highly inclusive one. For that reason we perform subtype reduction here if the
10557-
// union includes empty object types (e.g. reducing {} | string to just {}).
10558-
return getUnionType(widenedTypes, some(widenedTypes, isEmptyObjectType));
10554+
return getUnionType(sameMap((<UnionType>type).types, t => t.flags & TypeFlags.Nullable ? t : getWidenedTypeWithContext(t, unionContext)));
1055910555
}
1056010556
if (isArrayType(type) || isTupleType(type)) {
1056110557
return createTypeReference((<TypeReference>type).target, sameMap((<TypeReference>type).typeArguments, getWidenedType));

0 commit comments

Comments
 (0)