TypeScript Got a New Utility Type

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

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

  • @SoreBrain
    @SoreBrain 8 месяцев назад +7

    That little bit of excalidraw really helped to make the point clear.

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

      ruclips.net/video/SlKJO91bTJk/видео.htmlsi=sARuxpmK_2S0qe2v

  • @hyperprotagonist
    @hyperprotagonist 8 месяцев назад +36

    Hello Matt Pocock if he was 30 years younger with hair 👋

    • @АндрейЕвстратов-т3н
      @АндрейЕвстратов-т3н 8 месяцев назад +3

      Lol he’s not that old😅

    • @hyperprotagonist
      @hyperprotagonist 8 месяцев назад +2

      @@АндрейЕвстратов-т3нI know, but it puts more emphasis on Josh’s baby face.

    • @ludwignagelhus524
      @ludwignagelhus524 8 месяцев назад +5

      I think the emphasis falls on Pocock's lack of hair lol

    • @avid459
      @avid459 8 месяцев назад +1

      Matt is an old Typescript emperor from the far away , strange, cold and dark English speaking lands, whereas this teenager is our new eastern European local legend.
      Will he oust the old emperor whose tyranny of not being in support of '.ts' file extension imports is well known
      or will he join hands with the old emperor.
      only time will tell.

    • @akam9919
      @akam9919 6 месяцев назад +1

      @@hyperprotagonist So...two kills one roast?

  • @marusdod3685
    @marusdod3685 8 месяцев назад +2

    fuck I really needed this. was pulling my hairs out a month ago because it was just not narrowing down the type

  • @juanferrer5885
    @juanferrer5885 8 месяцев назад +4

    function configureDevice(
    allowOs: OS[],
    defaultOs?: OSDefault
    ) {
    //...
    }
    this works also
    great video Josh!

    • @dealloc
      @dealloc 8 месяцев назад +1

      Yes that's the "old" way of getting around it. But NoInfer makes it possible without having to deal with additional generics for bookkeeping.

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

      @@dealloc note also that previously NoInfer was possible using a user-defined type (and worked in almost all cases):
      type NoInfer = [T][T extends T ? 0 : never]
      (it hides the type behind a conditional type, which TS resolves after other inference)

  • @ahammadalipk
    @ahammadalipk 8 месяцев назад +1

    Great video first of all, out of curiosity, would like to know what tool is used for sketching?

  • @seroltech118
    @seroltech118 8 месяцев назад +2

    Thank your for this video. But the second example is soooo complicated. A simple enum type would solve everything. Guys remember, you use Ts to simplify the reading of your code and avoid bugs ? Or to write ambiguous code ?

    • @catte_6376
      @catte_6376 8 месяцев назад +2

      no, an enum wouldn't solve anything because the whole point is that the type ("OS") is provided by the user (because the function is generic). the user can obviously then choose to prevent this "ambiguity" through an enum/union by providing the type parameter rather than inferring it, which, for this simple example, is rather inconvenient: ```configureDevice(...)```

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

      It is actually very simple if you continued watching and didn't pause the moment you saw "configureDevice" lol.
      The problem lies in peple thinking it is outside their domain but he was only trying to give a real world example that'd make sense rather than A, B, C, and whatever.
      And while I could agree a generic example would be certainly simpler, it wouldn't answer the question "Well, what's the point of it?!"; so a real example was needed to open our eyes more into how useful it could be.

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

    Insta like!

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

    4th view 💪🏻

  • @bs8028
    @bs8028 8 месяцев назад +1

    We don’t need typescript

    • @BayarjavkhlanBatgerel
      @BayarjavkhlanBatgerel 8 месяцев назад +2

      only you dont need ts

    • @MichaelChanCY
      @MichaelChanCY 8 месяцев назад +2

      You don’t need to use TS if you don’t need it, but nobody is interested in what you need.

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

      Give me one thing you can’t do without ts

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

      ​@@bs8028oh wow really? you have to learn a lot...

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

      ​@@bs8028 make an application more legible and easy to maintain lol

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

    TS is getting more and more complicated. is Dart this complicated? I don't think so.

    • @PanosPitsi
      @PanosPitsi 8 месяцев назад +10

      I know it will sound crazy but nobody’s forcing you to use these features.

  • @riveto_ir
    @riveto_ir 8 месяцев назад +1

    Josh you're not planning on celebrating 100k youtube followers? People kill to get there 🎉😊

  • @thekwoka4707
    @thekwoka4707 7 месяцев назад

    Return a Rounded number, okay well return a number string with 2 decimal points
    Uh....

  • @TalhaBalaj
    @TalhaBalaj 8 месяцев назад +1

    love the quick explanations.

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

    Great video! Cool!

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

    Great Video

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

    Great video! Very simple examples that showcase the original problem and how these features take care of them.

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

    First View😅

  • @akam9919
    @akam9919 6 месяцев назад

    For those wondering how to get around the bug with NoInfer in the latest version, here is an alternative that does basically the same thing.
    type NoInfer=[T][T extends any? 0:never]