Satisfies Operator - new TypeScript 4.9 feature!

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

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

  • @hyperprotagonist
    @hyperprotagonist Год назад +25

    You explain it better than the docs 😂

  • @mikedelcastillo
    @mikedelcastillo Год назад +3

    great video as always! glad to see some coverage on this. great example too! i wish they'd have other syntax for this. something like `const config: Satisfies` or `const config: satisfies Config` just so the important bit isn't all the way at the end.

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

    Imho the best explanation of satisfies that I watched/read so far. A real life example is what is needed to best explain when to use it

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

    Jesus christ I was lacking this feature for years. Its very helpful when using with typeof of this config. There was no way to create safely typed object without ruining inference to some very broad useless type. Great explanation for someone without clue of this problem

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

    Such precise and helpful explanation. You are my go-to-guy for typescript.

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

    A great explanation of Satisfies. I can't say whether it's the best I've seen as I was 80% of the way there but it's up at the top.

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

    OMG i love this channel

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

    Very nice example!

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

    Excellent explanation! Great job. I was so impressed I subscribed :)

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

    Fantastic example! … but at the end 5:32, what if you changed the tryReconnect on line 22 to a boolean… wouldn’t line 28 cause an error?

  • @허바드제이콥
    @허바드제이콥 Год назад

    amazing explanation thank you

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

    awesome. love these vids. Not a second wasted.

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

    Nice! You thought of a good example instead of copying the "satisfies User" one, seen in like every other RUclips video on this topic. Nice explanation as well!

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

    Nice vid, thank you!

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

    What is the benefit of using `satisfies` instead of just typing it to the `Config` object?

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

    I guess I'm a little puzzled with whether or not you could then change tryReconnect in const config to a regular boolean and if it would show a type error within the start function's createConnection call since it's trying to call tryReconnect, which is now just a regular boolean.
    I guess this is mostly for when the data isn't expected to change, so you can write start() assuming config is a specific shape of Config (with `${port}`, and tryReconnect()).

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

    Satisfies has the same semantics as extends for generics right? Satisfies is basically just top level generics.

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

      Kinda! I think of extends a little differently, since in a generic like ‘T extends User’, we know nothing about T except what we know about User, so we can only treat T as a User. Satisfies is the reverse, where the initial type is narrower than the type it satisfies.

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

      @@andrew-burgess Oh yeah, you're right. There is significant overlap, but extends would accept extra props where as satisfies would not.

  • @45g4rerf45f45
    @45g4rerf45f45 Год назад

    Is there any reason not to use "satisfies" now?

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

    the docs are using a stupid example, your code are far more clear with actually more examples in it

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

    👎👎