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.

Комментарии • 27

  • @ffedchik
    @ffedchik 2 года назад +8

    This man deserves a massive respect! Appreciate the content you are sharing with us.

    • @aram5642
      @aram5642 Год назад

      Besides all, I love Andrew's well-articulated English at a very natural pace. Pleasure to listen to.

  • @GameKornel
    @GameKornel 2 года назад +3

    Love the exhaustive switch trick! Great video!

  • @Nscb1947
    @Nscb1947 Год назад

    I went through many blogs and videos for type narrowing but none explained the way you did. This was absolute gold. Thank you.

  • @sufyankhatri1
    @sufyankhatri1 8 месяцев назад

    Great explanation. You delivered it perfectly thank you for the upload

  • @abhirammadhu2973
    @abhirammadhu2973 Год назад

    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😊

  • @MindlessTurtle
    @MindlessTurtle Год назад

    Awesome video. Very educational.

  • @venzkie89
    @venzkie89 Год назад

    Very well explained! 👏👏👏

  • @Fishamble
    @Fishamble Год назад +1

    Great content. Have a comment for the algorithm.

  • @qkqk4317
    @qkqk4317 2 года назад

    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!

    • @andrew-burgess
      @andrew-burgess  2 года назад

      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!

  • @benjamin-lieb
    @benjamin-lieb 8 месяцев назад

    Excellent!

  • @MauroGestoso
    @MauroGestoso 2 года назад

    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.

  • @aram5642
    @aram5642 Год назад +1

    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.

    • @andrew-burgess
      @andrew-burgess  Год назад +1

      Thanks for watching! And thanks for the feedback! I’ll play around with several ways to make the text bigger 👍

  • @alessandroferrari2166
    @alessandroferrari2166 2 года назад +2

    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)!

    • @andrew-burgess
      @andrew-burgess  2 года назад

      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!

  • @rishabhnehra1471
    @rishabhnehra1471 8 месяцев назад

    Great video

  • @edgarabgaryan8989
    @edgarabgaryan8989 2 года назад

    i have learned some new stuff! thanks!

  • @Elator11777
    @Elator11777 Год назад +1

    Nice watch on your wrist.

  • @nomadshiba
    @nomadshiba Год назад +1

    can also use instanceof of classes

  • @programacion3694
    @programacion3694 10 месяцев назад

    buen video.

  • @aram5642
    @aram5642 Год назад +2

    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?

    • @andrew-burgess
      @andrew-burgess  Год назад

      Good question! I’m actually working on a video about the differences between type and interface right now!

  • @Funhouse4420
    @Funhouse4420 2 года назад

    Great tutorial. Please make the editor larger in new videos. Thanks

    • @andrew-burgess
      @andrew-burgess  2 года назад

      Thanks for watching, and thanks for the feedback! I’ll make sure the font is more readable in the future.

  • @sam.kendrick
    @sam.kendrick Год назад +2

    Thanks for the information. I took some notes here: docs.google.com/document/d/e/2PACX-1vSsm6Kqgi2I7q87U_zGXvpnyH6eOHuDYX2_GFwvi0-MyBPvmWz9GD5D30ignJAUw0JJr2-PvEKmY5lC/pub