Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 818 Bytes

File metadata and controls

32 lines (23 loc) · 818 Bytes

Home > types-kit > MergeTuple

MergeTuple type

Merge two tuples, values of the second array will override values of the array type.

Signature:

export type MergeTuple<
  A extends readonly unknown[],
  B extends readonly unknown[],
> = If<
  IsReadonlyArray<B>,
  readonly [...B, ...Slice<A, B['length']>],
  [...B, ...Slice<A, B['length']>]
>

References: If, IsReadonlyArray, Slice

Example

type Foo = [1, 2, 3]
 type Bar = [4, 5]
 // Expect: [4, 5, 3]
 type MergedTuple = MergeTuple<Foo, Bar>