Keyword: Satisfies in TypeScript

Поделиться
HTML-код
  • Опубликовано: 2 янв 2025

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

  • @fullfungo
    @fullfungo 8 дней назад +3

    Satisfies doesn’t “widen the type”. It doesn’t change the type in any way.
    It simply validates that the type of the expression is assignable to the one you provide.

    • @HunterScript
      @HunterScript  8 дней назад

      You are right! I think my error here was my teaching approach of blending the example into the syntax.

  • @ryanvarley2391
    @ryanvarley2391 8 дней назад +1

    Nicely explained man, that made a lot of sense. Now, I wonder if you have a video that shows me where I’m going wrong with the `unknown` type…

    • @HunterScript
      @HunterScript  8 дней назад

      Thanks man! I am glad that you got something out of the video.
      Yes, I do have a short on unknown:
      ruclips.net/user/shorts8NfPR2NsgtA
      Main Takeaway:
      Any -> can be any type, but turns off type-checking
      Unknown can be any type, but does NOT turn off type-checking.
      This is also a good follow-up video to see the difference in action:
      ruclips.net/user/shortsNom_q7Mpr2g
      Hope it helps! 😎👍