Type Narrowing in TypeScript
HTML-код
- Опубликовано: 23 авг 2024
- Union types are pretty common in TypeScript, but how can you figure out which type you're actually working with in a given scenario? Type narrowing is all about the ways to determine what shape you have, and we'll look at a couple ways to do it in this video.
This man deserves a massive respect! Appreciate the content you are sharing with us.
Besides all, I love Andrew's well-articulated English at a very natural pace. Pleasure to listen to.
Love the exhaustive switch trick! Great video!
I went through many blogs and videos for type narrowing but none explained the way you did. This was absolute gold. Thank you.
Great explanation. You delivered it perfectly thank you for the upload
This video is a gem😍. I always found it difficult to understand type predicates until you showed this brilliant example. Especially that part (6:10) where you showed that within the predicate the type has been narrowed down😊
Awesome video. Very educational.
Very well explained! 👏👏👏
Great content. Have a comment for the algorithm.
Any time you upload our codebase becomes a bit more legible. The exhaustive switch case is a great way to catch issues before the runtime. Gonna be removing a lot of throw statements tomorrow. Great stuff!
That means so much to me, so excited that you are finding these videos useful! If you topics that you’d like me to cover, don’t hesitate to let me know!
Excellent!
Great video, Andrew! I'm looking for ammunition to justify starting using TS at work and this will be very helpful. Doing all this defensive programming in vanilla JS is such a pain and so hard to enforce consistently.
I started to receive your videos among YT suggestion. And this is one of those moments when you really love those algorithms. Thanks for sharing your knowledge! Helps a lot. If you're open for a suggestion though... Please reduce the area with you face in favor of the coding area. May sound harsh, but it is nothing personal. On small mobile screens it is just very hard to follow the typing even in full screen. Thanks again.
Thanks for watching! And thanks for the feedback! I’ll play around with several ways to make the text bigger 👍
your explanations are very clear and to the point, thank you! Just as suggestion, you might want to tone down the music or change it altogether. At least for me, it's annoying, not sure for others. Anyway, keep up the great work and subscribed (also to the notifications)!
Thanks for the feedback! Still trying to figure out what works best for the music, will be sure to experiment with quieter / no music. Appreciate you subscribing!
Great video
i have learned some new stuff! thanks!
Nice watch on your wrist.
can also use instanceof of classes
buen video.
Just curious. One could probably use 'interface' + 'extends' to achieve what you achieved with 'type' + &. Am I correct? If so, is this just a matter of preference, or is there a subtle difference between those two options?
Good question! I’m actually working on a video about the differences between type and interface right now!
Great tutorial. Please make the editor larger in new videos. Thanks
Thanks for watching, and thanks for the feedback! I’ll make sure the font is more readable in the future.
Thanks for the information. I took some notes here: docs.google.com/document/d/e/2PACX-1vSsm6Kqgi2I7q87U_zGXvpnyH6eOHuDYX2_GFwvi0-MyBPvmWz9GD5D30ignJAUw0JJr2-PvEKmY5lC/pub