File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -22168,8 +22168,17 @@ namespace ts {
22168
22168
// constituent types keyed by the literal types of the property by that name in each constituent type.
22169
22169
function getKeyPropertyName(unionType: UnionType): __String | undefined {
22170
22170
const types = unionType.types;
22171
- // We only construct maps for large unions with non-primitive constituents.
22172
- if (types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion) {
22171
+ // We only construct maps for unions with many non-primitive constituents.
22172
+ let nonPrimitiveCount = 0;
22173
+ const isLargeNonPrimitives = types.length >= 10 && !(getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion) &&
22174
+ forEach(types, t => {
22175
+ if (t.flags & (TypeFlags.Primitive | TypeFlags.AnyOrUnknown | TypeFlags.Never)) {
22176
+ return
22177
+ }
22178
+ nonPrimitiveCount++;
22179
+ return nonPrimitiveCount >= 10;
22180
+ });
22181
+ if (!isLargeNonPrimitives) {
22173
22182
return undefined;
22174
22183
}
22175
22184
if (unionType.keyPropertyName === undefined) {
You can’t perform that action at this time.
0 commit comments