This is why learning typescript generics is important

  Рет қаралды 25,623

Web Dev Cody

Web Dev Cody

Күн бұрын

Пікірлер: 68
@st-jn2gk
@st-jn2gk Жыл бұрын
You're like if "Common Sense" was a programmer. You don't have any ridiculous esoteric pseudo-advice to give, but you just stick to the basics and make cool stuff. Validates "the basics" in a climate where you either use vim and program in c/rust, or you use vscode and write next 13 apps. I'm really glad I found this channel.
@jly_dev
@jly_dev 9 ай бұрын
The more difficult parts of TS (generics, mapped/recursive/conditional types, etc) are not easy to learn from the docs by themselves. Gabriel Vergnaud's Type-Level TypeScript was a really helpful resource for me, and I've heard good things about TypeHero
@philheathslegalteam
@philheathslegalteam Жыл бұрын
Didn't take you long to become my favourite tech KZbinr. Perfect no-nonsense approach to videos, ability to call things out for what they are and diving into technical content like this and that custom framework you're on currently. Your videos are a goldmine when it comes to reaffirm knowledge and see different use cases for different strategies. Really appreciate the work you're putting into this channel and its content!
@WebDevCody
@WebDevCody Жыл бұрын
Thanks man!
@leonauswien
@leonauswien Жыл бұрын
"That's something that's really important when building a libary, is start with the interface - how a people paying to consume your functions / interface" Such a valuable tip, applies to any function / structure; it helps a lot to find a good "how" to think about the user first. Really good content! Not much new stuff in this video for me, but subbed for the conciseness and the calming voice.
@monstajoedev
@monstajoedev Жыл бұрын
Such an amazing tutorial. I used it before to create a local storage hook, which is one of those rare cases where you have to create a generic function.
@treyrader
@treyrader 8 ай бұрын
I used it for the same situation a few days ago. good stuff
@dannycollazo9165
@dannycollazo9165 Жыл бұрын
Such a great video! This made me realize that not all TS is difficult and actually fun to write. Love the content, keep it up!
@bowaller6892
@bowaller6892 Жыл бұрын
Im not a guy of typescript but I try to learn on the future. This video was awesome about generics good example and explain.
@megamind452
@megamind452 Жыл бұрын
Great quality of info, nicely done 👍
@leebobtheblob87
@leebobtheblob87 Жыл бұрын
6:11 extends key of TStore 7:19 using generic to control user set input 9:12 callback signature 12:14 ReturnType
@Ganidv
@Ganidv Жыл бұрын
It’s a great video, thank you. I hope there will be more videos about this topic. Great work!
@florianwebdev
@florianwebdev 7 ай бұрын
Well done explaining generics! You earned a new subscriber
@barssavas9938
@barssavas9938 Жыл бұрын
Such an amazing educative content. I learned a lot from you. And I am applying it to my and my company's codebase.
@TheEchinox
@TheEchinox Жыл бұрын
To the point. As per usual, Cody delivers! Keep it up!
@mikecebul
@mikecebul Жыл бұрын
This was extremely helpful.
@eshw23
@eshw23 Жыл бұрын
Dont stop making videos ever lol some of these random topics end up saving me in my project
@juanmacias5922
@juanmacias5922 Жыл бұрын
This was impressive, generics seems to be my next step in understanding TS. :D
@abdiraqiibmohummed9781
@abdiraqiibmohummed9781 Жыл бұрын
great videos man , i eat breakfast while watching your videos , always great content , keep it up man !!!
@doc8527
@doc8527 Жыл бұрын
Though there is not "class keyword" involved, but the way you handle it is just OOP, because you want all the "object" to inherit the get/set function, that's why the "generic" kicks in. It could be a pattern for library author, but pretty much not for application level app.
@imsirpak
@imsirpak Жыл бұрын
Thanks for the video!
@muhammad_ramadan
@muhammad_ramadan Жыл бұрын
Fantastic video, great job 👏
@nidhishsrivastava4868
@nidhishsrivastava4868 Жыл бұрын
I just used it while creating a hook for storing my items in local storage
@fluntimes
@fluntimes 10 ай бұрын
As I was watching I was wondering the difference between and . I guess I'm more familiar with the second structure.
@elmalleable
@elmalleable Жыл бұрын
super cool, i build something similar a month ago because i just wanted redux toolkit kind of functionality in an old angular js file using rxjs i had to use jsdocs but still works nice
@AjayGopalShresthaAGS
@AjayGopalShresthaAGS Жыл бұрын
I tried using this pattern with useMap hook in react, The definition is the same for this and useMap, but the useMap value type has type of all values combined.
@nsatempe
@nsatempe 13 күн бұрын
What is the extension that puts the solid yellow line around your current function/scope? It doesn’t appear to be in the Bearded theme or rainbow indent and I didn’t see it in your themes video.
@goodgoing4615
@goodgoing4615 Жыл бұрын
This question is off-topic, but I wanted to ask if the glasses you are using are some kind of blue filter glasses. I've been having dry eye-related issues lately because of coding. Thanks for all the videos.They are very valuable.
@WebDevCody
@WebDevCody Жыл бұрын
No they are just normal glasses
@slahomar1497
@slahomar1497 Жыл бұрын
As a senior JavaScript/TypeScript developer, if you're considering branching out into another backend programming language, what would be a wise choice? Many developers commence their journey with JavaScript, and the job market is becoming increasingly competitive in this domain. In this context, how do you view languages like Go, Ruby, and Java?
@WebDevCody
@WebDevCody Жыл бұрын
I’d be interested in working with go personally
@Ikakoo2410
@Ikakoo2410 Жыл бұрын
Thanks Cody
@SeibertSwirl
@SeibertSwirl Жыл бұрын
Good job babe!!
@tushar8133
@tushar8133 Жыл бұрын
Wow! Thanks!
@sabirameen5672
@sabirameen5672 Жыл бұрын
I too had the same problem when working on my side project. Nextjs caching is too aggressive imo. For invalidating router cache, they provide the router.refresh().
@randomforest_dev
@randomforest_dev Жыл бұрын
nice one!
@Sherloqui
@Sherloqui Жыл бұрын
Great video, to the point!
@goa213
@goa213 Жыл бұрын
Awesome video!
@fullstack_journey
@fullstack_journey Жыл бұрын
Nice tuts 👍
@EmmanuelOdii80
@EmmanuelOdii80 Жыл бұрын
@abdulrahmanalsabagh3334
@abdulrahmanalsabagh3334 Жыл бұрын
The video reminds me on the days where u used to hate TS 😅 Anyway Very cool video 🎉
@WebDevCody
@WebDevCody Жыл бұрын
I’m less of a noob now 😆
@carlosvalderrama3207
@carlosvalderrama3207 Жыл бұрын
Can you do a video showing us your VSCode theme?
@h4nto772
@h4nto772 Жыл бұрын
it’s bearded stained blue
@yashsolanki069
@yashsolanki069 Жыл бұрын
Is this a shades of purple theme?
@WebDevCody
@WebDevCody Жыл бұрын
Bearded theme stained blue
@yashsolanki069
@yashsolanki069 Жыл бұрын
@@WebDevCody thanks ser!
@rand0mtv660
@rand0mtv660 Жыл бұрын
Do get/set really require generics here? Since types for those are constructed from passed in data there is no need to be able to pass generics to those functions to tell it what types it has or to override/extend something. Instead of using K for example, I think for this particular case it would be better to just write "key: keyof T" without exposing generics here. Good example nonetheless!
@VictorMachadoDeFranca
@VictorMachadoDeFranca Жыл бұрын
doing this way, you lose type inference for the values by making a generic constraint, typescript will infer the value at the specific key declared as K T[keyof T] is the union of all types of T attributes
@rand0mtv660
@rand0mtv660 Жыл бұрын
@@VictorMachadoDeFranca You are right. I had to see it for myself and I tested this and by not using generics in this example and using what I said in my comment, return type for .get() will be a union of all types from all keys of T. Same goes for .set(), value accepted will be a union of all those types. Huh, I thought generics were unnecessary here, but I guess I was wrong. Well, you learn something new every day :D
@WebDevCody
@WebDevCody Жыл бұрын
I guess typescript isn’t smart enough to know what key specifically is being passed into the callback
@mjsigg
@mjsigg Жыл бұрын
Just asking but why not just make a class for the store and use a constructor? Trying to learn TS.
@WebDevCody
@WebDevCody Жыл бұрын
No reason, I just default to functions usually
@ameerashhab6721
@ameerashhab6721 Жыл бұрын
Class based programming is a style, and so is functional programming. You can pick whatever you want. All companies I worked for though, their projects are functional. Classes are annoying to work with, or rather OOP style.
@aigabuskira165
@aigabuskira165 Жыл бұрын
this is good, and thanks for the video.
@treyrader
@treyrader 8 ай бұрын
this is solid lol
@codyf1
@codyf1 Жыл бұрын
Is this future me? I really hope not, because I don't like javascript that much
@aspirinemaga
@aspirinemaga Жыл бұрын
0:20 as a non ts dev, I almost vomit seeing that code just for "dev-friendly-development"
@elpolodiablo5486
@elpolodiablo5486 Жыл бұрын
As a TS dev, I almost vomit seeing your stupid comment.
@WebDevCody
@WebDevCody Жыл бұрын
Why? At 20 seconds in the only typescript code I use is defining a type and passing a generic
@oscarljimenez5717
@oscarljimenez5717 Жыл бұрын
Yeah, you have never use generics in any language :)
@MarkPanado
@MarkPanado Жыл бұрын
2 space indention is hard for my eyes
@WebDevCody
@WebDevCody Жыл бұрын
sorry, it's the format I use
@aleaallee
@aleaallee Жыл бұрын
Generics seem kinda complex and off-putting to me.
@michakrecisz5100
@michakrecisz5100 Жыл бұрын
it's very cool but nobody should call that "easy to read".
Why I'll always use Typescript over Javascript
18:17
Web Dev Cody
Рет қаралды 17 М.
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 141 М.
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 23 МЛН
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 35 МЛН
Generics in Typescript for Beginners - Learn by Doing
18:59
Monsterlessons Academy
Рет қаралды 4,4 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,8 МЛН
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 181 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 67 М.
Typescript Generics | Beginners Tutorial with Examples
24:43
Dave Gray
Рет қаралды 18 М.
Typescript Generics Tutorial
21:56
Ben Awad
Рет қаралды 219 М.
A Jr Dev For Life?? | Prime Reacts
21:33
ThePrimeTime
Рет қаралды 318 М.
Senior Typescript Features You don't Know About - clean-code
13:33
Golang: The Last Interface Explanation You'll Ever Need
17:58
Flo Woelki
Рет қаралды 19 М.
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 23 МЛН