Type Alias TupleIntersect<ARR1, ARR2, N>

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

create an element-wise intersection between two tuples.
note that the intersection any & T typically produces any, but when put through this utility type, it will produce T for convenience of usage with function parameters intersection.

Type Parameters

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