Includes type in TypeScript
16 Apr 2021
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:
Afterwards we make sure we have an element U
in the union of all elements from the tuple:
The solution as always is available on Playground
typescript