TypeScript Got a New Utility Type

Sdílet
Vložit
  • čas přidán 28. 06. 2024
  • I like what the TypeScript team is doing. These updates are to the point, nicely communicated with their blog, and serve a purpose.
    TypeScript Playground (select "nightly" for the 5.4): www.typescriptlang.org/play
    Great blog article: devblogs.microsoft.com/typesc...
    -- my links
    Newsletter: www.joshtriedcoding.com/
    Discord: / discord
    GitHub: github.com/joschan21
  • Věda a technologie

Komentáře • 43

  • @SoreBrain
    @SoreBrain Před 5 měsíci +6

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

    • @JohnWasinger
      @JohnWasinger Před 5 měsíci

      czcams.com/video/SlKJO91bTJk/video.htmlsi=sARuxpmK_2S0qe2v

  • @TalhaBalaj
    @TalhaBalaj Před 5 měsíci

    love the quick explanations.

  • @juanferrer5885
    @juanferrer5885 Před 5 měsíci +3

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

    • @dealloc
      @dealloc Před 4 měsíci +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 Před 4 měsíci

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

  • @Fullflexno
    @Fullflexno Před 5 měsíci

    Great video! Cool!

  • @FurryDanOriginal
    @FurryDanOriginal Před 5 měsíci

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

  • @ahammadalipk
    @ahammadalipk Před 5 měsíci +1

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

  • @marusdod3685
    @marusdod3685 Před 4 měsíci +1

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

  • @hyperprotagonist
    @hyperprotagonist Před 5 měsíci +34

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

    • @user-pq8zg6rx8c
      @user-pq8zg6rx8c Před 5 měsíci +3

      Lol he’s not that old😅

    • @hyperprotagonist
      @hyperprotagonist Před 5 měsíci +2

      @@user-pq8zg6rx8cI know, but it puts more emphasis on Josh’s baby face.

    • @ludwignagelhus524
      @ludwignagelhus524 Před 5 měsíci +5

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

    • @avid459
      @avid459 Před 5 měsíci +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 Před 3 měsíci +1

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

  • @fenix2598
    @fenix2598 Před 5 měsíci

    Great Video

  • @riveto_ir
    @riveto_ir Před 5 měsíci

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

  • @seroltech118
    @seroltech118 Před 5 měsíci +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 Před 5 měsíci +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 Před 4 měsíci

      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.

  • @jordan9506
    @jordan9506 Před 5 měsíci

    Insta like!

  • @thekwoka4707
    @thekwoka4707 Před 4 měsíci

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

  • @thecodermehedi
    @thecodermehedi Před 5 měsíci

    4th view 💪🏻

  • @akam9919
    @akam9919 Před 3 měsíci

    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]

  • @soheilweb
    @soheilweb Před 5 měsíci

    First View😅

  • @greendsnow
    @greendsnow Před 5 měsíci

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

    • @user-fr2fm3ri3w
      @user-fr2fm3ri3w Před 5 měsíci +10

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

  • @bs8028
    @bs8028 Před 5 měsíci +1

    We don’t need typescript

    • @BayarjavkhlanBatgerel
      @BayarjavkhlanBatgerel Před 5 měsíci +2

      only you dont need ts

    • @MichaelChanCY
      @MichaelChanCY Před 5 měsíci +2

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

    • @bs8028
      @bs8028 Před 5 měsíci

      Give me one thing you can’t do without ts

    • @CrAzZyKiLleR01
      @CrAzZyKiLleR01 Před 5 měsíci

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

    • @retrosynthguy
      @retrosynthguy Před 5 měsíci

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