Course contentsShow
← TypeScript
Lesson 443 of 1,79610. Intersection TypesFree lesson

Index Signature Conflicts

What happens when intersecting types with conflicting index signatures and how to resolve them.

Index Signature Conflicts

You'll learn what happens when intersection types contain conflicting index signatures and how TypeScript resolves them.

What the Problem Is

When you intersect two types that each have index signatures, TypeScript needs to reconcile those signatures. Unlike regular properties that can conflict, index signatures apply to all properties matching their key type—so conflicts here affect the entire type.

How TypeScript Resolves Conflicts

When intersecting types with index signatures, TypeScript applies the same rule as property conflicts: the resulting index signature is the intersection of the value types.

type StringRecord = {
  [key: string]: string;
};

type NumberRecord = {
  [key: string]: number;
};

// The intersection creates an impossible constraint
type Conflict = StringRecord & NumberRecord;
// Index signature resolves to: [key: string]: string & number
// Which is: [key: string]: never

Since string & number is never, you cannot assign any values to this type—it's unusable.

Resolutions and Practical Patterns

The key is ensuring your index signatures are compatible before intersecting:

type BaseRecord = {
  [key: string]: string | number;
};

type StringRecord = {
  [key: string]: string;
};

// This works! string extends string | number
type Valid = BaseRecord & StringRecord;
// Results in: [key: string]: string

The narrower type (string) wins because it satisfies the broader constraint (string | number).

Key Takeaway: When intersecting types with index signatures, the resulting signature is an intersection of the value types—ensure they're compatible or you'll end up with never, making the type unusable.