Type Alias TupleUnion<ARR1, ARR2, N>

TupleUnion<ARR1, ARR2, N>: N extends number
    ? UnionKnown<ARR1[N], ARR2[N]> extends undefined | never
        ? []
        : [UnionKnown<ARR1[N], ARR2[N]>, ...TupleUnion<ARR1, ARR2, IncrementNumber[N]>]
    : []

create an element-wise intersection between two tuples. note that the intersection any & T does not produce T for some reason unfortunately.

Type Parameters

  • ARR1 extends any[]
  • ARR2 extends any[]
  • N extends number | never = 0
type A = TupleUnion<[number, unknown, string, boolean], [5, number, string, any, 99]>
// A === [number, number, string, boolean>, undefined | 99]