Generics to work with union/tuple in typescript
https://github.com/livelybone/union-tuple.git
https://github.com/livelybone/union-tuple#readme
npm i -S union-tuple
See what method or params you can use in index.d.ts
import { IsTuple } from 'union-tuple'
type Foo = IsTuple<[1, 2]>
const foo: Foo = true
import { TupleToUnion } from 'union-tuple'
type Foo = TupleToUnion<[1, 2]>
const foo: Foo = 1
import { UnionPop } from 'union-tuple'
type Foo = UnionPop<1 | 2>
const foo: Foo = 2
import { TuplePrepend } from 'union-tuple'
type Foo = TuplePrepend<[1, 2], 3>
const foo: Foo = [3, 1, 2]
import { UnionToTuple } from 'union-tuple'
type Foo = UnionToTuple<1 | 2 | 3>
const foo: Foo = [1, 2, 3]
import { UnionToTuple } from 'union-tuple'
type Foo = UnionToTuple<1 | 2 | 3>
const foo: Foo = [1, 2, 3]
import { UnionToTupleWithMap } from 'union-tuple'
type Foo = UnionToTupleWithMap<1 | 2 | 3, { 1: 'a', 2: 'c', 3: [1, 2] }>
const foo: Foo = ['a', 'c', [1, 2]]
import { TupleMap } from 'union-tuple'
type Foo = TupleMap<[2, 1, 3], { 1: 'a', 2: 'c', 3: [1, 2] }>
const foo: Foo = ['c', 'a', [1, 2]]