Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28027,15 +28027,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// 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
countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.InstantiableNonPrimitive))) < 10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition matches now the existing flags check in mapTypesByKeyProperty (that function is already called only from within the containing function here - getKeyPropertyName)

) {
return undefined;
}
if (unionType.keyPropertyName === undefined) {
// The candidate key property name is the name of the first property with a unit type in one of the
// constituent types.
const keyPropertyName = forEach(types, t =>
t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive) ?
t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.InstantiableNonPrimitive) ?
forEach(getPropertiesOfType(t), p => isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined) :
undefined);
const mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName);
Expand Down