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

Alexey Berezin

Senior Software Engineer, UK Global Talent 🇬🇧

The portrait photo of me

Thank you for reading my blog post! If you have any questions, suggestions, or just want to say hi, feel free to reach out in social networks, or via email. I would love to hear from you!

Comments