Type alias ArrayIntersection<Arr>

ArrayIntersection<Arr>: Arr extends readonly [infer First, ...(infer Rest)]
    ? Extract<ArrayValue<First>, ArrayIntersection<Rest>>
    : unknown

Calculates the intersection of the types within an array Arr of tuple types.

Type Parameters

  • Arr extends readonly unknown[]

Returns

The types present in every tuple, if any.

Example

ArrayIntersection<[[1, 0, 1], [0, 1, -1], [0, 0, 1]]>; // 0 | 1
ArrayIntersection<[[1, 0], [0, 1], [0, 0]]>; // 0
ArrayIntersection<[[1, 0], [-1, -1], [-8, -9]]>; // never