View all snippets

Distributive Intersect

Intersect an object with each object in a union, preserving the union types.

export type DistributiveIntersect<
  T,
  K extends { [key in keyof T]?: unknown },
> = T extends unknown ? Omit<T, keyof K> & K : never;