TupleToUnion<T>
EasyP2Coding
Implement TupleToUnion<T>, the union of all element types of a tuple T.
Tests your type must pass
type cases = [ Expect<Equal<TupleToUnion<[123, '456', true]>, 123 | '456' | true>>, Expect<Equal<TupleToUnion<[123]>, 123>>, Expect<Equal<TupleToUnion<[]>, never>>, Expect<Equal<TupleToUnion<readonly ['a', 'b']>, 'a' | 'b'>>, ]
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
TypeScript
Run and Submit type-check your solution against the tests. ⌘Enter runs, ⌘⇧Enter submits.