TypeScript Got a New Utility Type
Ғылым және технология
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
Пікірлер: 43
That little bit of excalidraw really helped to make the point clear.
@JohnWasinger
3 ай бұрын
kzread.info/dash/bejne/haB_rLFyYcW6es4.htmlsi=sARuxpmK_2S0qe2v
Hello Matt Pocock if he was 30 years younger with hair 👋
@user-pq8zg6rx8c
3 ай бұрын
Lol he’s not that old😅
@hyperprotagonist
3 ай бұрын
@@user-pq8zg6rx8cI know, but it puts more emphasis on Josh’s baby face.
@ludwignagelhus524
3 ай бұрын
I think the emphasis falls on Pocock's lack of hair lol
@avid459
3 ай бұрын
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
2 ай бұрын
@@hyperprotagonist So...two kills one roast?
function configureDevice( allowOs: OS[], defaultOs?: OSDefault ) { //... } this works also great video Josh!
@dealloc
3 ай бұрын
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
3 ай бұрын
@@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)
love the quick explanations.
Great video! Very simple examples that showcase the original problem and how these features take care of them.
fuck I really needed this. was pulling my hairs out a month ago because it was just not narrowing down the type
Great video first of all, out of curiosity, would like to know what tool is used for sketching?
@nicolasgomez5207
3 ай бұрын
Exacalidraw
@ahammadalipk
3 ай бұрын
@@nicolasgomez5207 thanks
Great video! Cool!
Great Video
Josh you're not planning on celebrating 100k youtube followers? People kill to get there 🎉😊
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
3 ай бұрын
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
3 ай бұрын
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.
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]
Return a Rounded number, okay well return a number string with 2 decimal points Uh....
Insta like!
4th view 💪🏻
@jatiquep5543
3 ай бұрын
825th view😂
First View😅
TS is getting more and more complicated. is Dart this complicated? I don't think so.
@user-fr2fm3ri3w
3 ай бұрын
I know it will sound crazy but nobody’s forcing you to use these features.
We don’t need typescript
@BayarjavkhlanBatgerel
3 ай бұрын
only you dont need ts
@MichaelChanCY
3 ай бұрын
You don’t need to use TS if you don’t need it, but nobody is interested in what you need.
@bs8028
3 ай бұрын
Give me one thing you can’t do without ts
@CrAzZyKiLleR01
3 ай бұрын
@@bs8028oh wow really? you have to learn a lot...
@retrosynthguy
3 ай бұрын
@@bs8028 make an application more legible and easy to maintain lol