types-kit.uniontosubtuplearray.md

September 4, 2023 ยท View on GitHub

Home > types-kit > UnionToSubTupleArray

UnionToSubTupleArray type

Get all sub tuple array from the passing parameter.

Signature:

export type UnionToSubTupleArray<T> = TupleKeys<UnionToTuple<T>> extends infer V
  ? V extends number
    ? GetSubTuple<V, T>
    : never
  : never

References: TupleKeys, UnionToTuple, GetSubTuple

Example

// Expect: ['a' | 'b'] | ['a' | 'b', 'a' | 'b']
type Foo = UnionToSubTupleArray<'a' | 'b'>

Contents

  1. 1UnionToSubTupleArray type
  2. 2Example