beraliv

Includes type in TypeScript

Example of Includes use
Example of Includes use

Tenth challenge is Includes

If you have a tuple and want to check if the specific value exists, this is a challenge for you.

Iteration over tuples

Similar what we discussed in Making object out of tuple, we can use Indexed Access Types to get all the elements from the tuple:

Get union from the tuple
Get union from the tuple

Afterwards we make sure we have an element U in the union of all elements from the tuple:

Solution
Solution

The solution as always is available on Playground

typescript

Comments

Alexey Berezin profile image

Written by Alexey Berezin who loves London 🏴󠁧󠁢󠁥󠁮󠁧󠁿, players ⏯ and TypeScript 🦺 Follow me on Twitter