From a9b9ec39eb4767e190cb11f918f5be615c7ebb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 8 Feb 2026 18:37:11 +0100 Subject: [PATCH] Properly account for intersections in `getKeyPropertyName` --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8fa3c4fce2a4a..585d6760c7c5b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28027,7 +28027,7 @@ 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 ) { return undefined; } @@ -28035,7 +28035,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // 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);