Skip to content

Commit a9b9ec3

Browse files
committed
Properly account for intersections in getKeyPropertyName
1 parent 87aa917 commit a9b9ec3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28027,15 +28027,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2802728027
// We only construct maps for unions with many non-primitive constituents.
2802828028
if (
2802928029
types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion ||
28030-
countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive))) < 10
28030+
countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.InstantiableNonPrimitive))) < 10
2803128031
) {
2803228032
return undefined;
2803328033
}
2803428034
if (unionType.keyPropertyName === undefined) {
2803528035
// The candidate key property name is the name of the first property with a unit type in one of the
2803628036
// constituent types.
2803728037
const keyPropertyName = forEach(types, t =>
28038-
t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive) ?
28038+
t.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.InstantiableNonPrimitive) ?
2803928039
forEach(getPropertiesOfType(t), p => isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined) :
2804028040
undefined);
2804128041
const mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName);

0 commit comments

Comments
 (0)