Type alias ArrayIntersection<Arr>

ArrayIntersection<Arr>: Arr extends [infer S, ...(infer E)]
    ? (S extends unknown[]
        ? S[number]
        : S) & ArrayIntersection<E>
    : unknown

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

Type Parameters

  • Arr extends unknown[]

Returns

The types that repeat, if exists

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