Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22168,8 +22168,9 @@ namespace ts {
// constituent types keyed by the literal types of the property by that name in each constituent type.
function getKeyPropertyName(unionType: UnionType): __String | undefined {
const types = unionType.types;
// We only construct maps for large unions with non-primitive constituents.
if (types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion) {
// We only construct maps for unions with many non-primitive constituents.
if (types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion ||
countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive))) < 10) {
return undefined;
}
if (unionType.keyPropertyName === undefined) {
Expand Down