Infer first element

Example of First use

Fourth challenge is First of Array

We can use it for both arrays and tuples, but for tuples you get exact value.

To distinguish arrays and tuples, please visit Making object out of tuple

Extracting first element

Previously we described how to iterate over tuples. For this challenge we don’t need it as we can access index directly using [0]:


But don’t forget about Generic Constrains using extends (it’s already added). Without it we cannot call T[0] and will get an error Type '0' cannot be used to index type 'T'

Thank you for your time! 🕒

If you interested in test cases, please have a look at Playground


Let's chat and have fun 🧑‍💻👩‍💻

No more often than once a week I write 📄 about TypeScript 💪, video playback 📺 and frontend related topics. You can unsubscribe in any time ↘️