Lookup Types (TypeScript super power)

preview_player
Показать описание
In this tutorial, we look at #TypeScript #Lookup #Types and how they can help clean up your code.

They have been around for a while and have been a great help when depending on external libraries and also with reducing type noise in real work codebases 🌹

🚥 Professional Courses

#basarat #typescript #tutorial

👇 SUBSCRIBE for MORE 👇

**Feel Free To Read This Lot**

I'm Basarat, That TypeScript Guy and I love helping developers. More about me:

Microsoft MVP for TypeScript
Lead Frontend Practice at Australia Post
150K contributions on Stackoverflow. Top Contributor for TypeScript.
Book Author : Beginning NodeJS
Book Author : TypeScript Deep Dive
Creator of multiple hot ✨ed Github Open Source projects

Рекомендации по теме
Комментарии
Автор

Using `[0]` to look up the type of an array works, but `[number]` also works and, in my opinion, captures better what is going on.

malvoliosf
Автор

I love these bite sized nuggets of knowledge. Thank you and keep up the amazing work 👏

NCmderShepard
Автор

Your videos are awesome. I wish the docs were this clear. Thanks!!

allanjuan
Автор

I didn’t know this, I’m enjoying your videos and style! Keep it up.

Gabzim
Автор

Enjoy your videos very concise and audio is great.

floy
Автор

To get type of an array property you should rather use number type instead of 0. It does basically the same, but in a case when an array is a tuple it changes everything.



I would recommend lookup types only in situation when the base type comes from external library.
Otherwise it would be much cleaner to split huge SubmitRequest type to multiple smaller subtypes.
You called it "type noise", but having one huge type definition generates super long unreadable type error messages.
With multiple smaller types, the code is easier to maintain and type errors are more dev friendly

bartosznowak
Автор

Briefly and to the point. Thank you, Basarat! You awesome!

Artem-uec
Автор

Damn man! Beautifully explained. I didn't know about this feature but I will start using it going forward to reduce 'Type noise'. I didn't know 'Type noise' was a thing. I do now. :)

adamdrake
Автор

Any docs around this pattern you can share?

DanielDominguez-sc
Автор

quality is only 360p only in my phone?

viniciusataidedealbuquerqu
Автор

The visual makes my tired eye shut off for an hour. Use zoom in to focus on the important stuff.

v