TypeScript Generics are EASY once you know this

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

ความคิดเห็น • 215

  • @jotasenator
    @jotasenator ปีที่แล้ว +135

    I was avoiding generics for a while for no reason, now, finally I will avoid it with a reason

    • @patfre
      @patfre ปีที่แล้ว +22

      And now employers are gonna avoid you for a reason

    • @jotasenator
      @jotasenator ปีที่แล้ว +14

      @@patfre auch! was a funny way to say the content is great and well explained but still generics are hard and verbose no matter what. Will be healthy a pole to show how many devs use generics in his job. Also if an employer doesn't select you because you don't use a specific content, well, that is not the place.

    • @patfre
      @patfre ปีที่แล้ว +3

      @@jotasenator the whole point of generics is the make thing generic, they are very helpful in making things type safe especially with how much TS allows you to do, I just used it today to make my code simpler and cleaner and not be 100 lines of repeated code. Also the thing about companies is they want safe and reliable code that follows best practices a lot so they can absolutely deny you for something like this if your 100% not willing to follow their practices with the code

    • @PlerbyMcFlerb
      @PlerbyMcFlerb ปีที่แล้ว

      ​@@jotasenatormight as well just avoid typescript while you're at it. Generics are what allow effective code reuse and sound typing to coexist

    • @jotasenator
      @jotasenator ปีที่แล้ว +2

      @@PlerbyMcFlerb the thing is I do use typescript, but never generics, in react.js and vue.js and next.js. I was watching this video because all the contents in here are explained in a way I like, still, don t see generics in the feature for me. Not saying I am against them, just I didn't find myself in a position saying: well, is time for generics...

  • @Bread-vk8fl
    @Bread-vk8fl 4 หลายเดือนก่อน +8

    1st time I watched it I got 80%, the 2nd time 95%. Now I just need to code myself to get it 100%. The best explanation of all TH-cam. Thank you so much.

  • @ashishboora3049
    @ashishboora3049 ปีที่แล้ว +22

    I am react developer and never used typescript, just out of curiosity started watching it. Now i am suddenly feeling like i know complete Typescript.
    I mean how well you explained it, i can understand every second of this video. This is really some next level teaching skill.

  • @timlind3129
    @timlind3129 ปีที่แล้ว +93

    Honestly - this is probably the best description / example I've seen yet! Keep it up!

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว +3

      Thanks, will do!

    • @Dan-p7f
      @Dan-p7f ปีที่แล้ว

      agree 100%

    • @mblackritter
      @mblackritter 9 หลายเดือนก่อน

      I've also to *SUPER AGREE* - it's like *finally* someone really explained how it works - instead of talking plain code! 😻 haha 😹💦

  • @bcb3548
    @bcb3548 8 หลายเดือนก่อน +2

    As someone who has been anxious even when seeing cryptic type notations, this lesson is almost like a therapy session. For me, adding just after writing the function name make sense than coming back to it after annotating arguments. It reads like "this function / class is meant to work with these types".. Thank you!

  • @sandeepamarnath3295
    @sandeepamarnath3295 3 หลายเดือนก่อน +3

    I wish I could like this video a 100 times. You are the best teacher ever who sticks to the point and every second is worth watching and learning. Great job!

  • @tomisadone1145
    @tomisadone1145 ปีที่แล้ว +7

    Spectacular video, had it open in a side tab for a month and I can't regret more not watching it before. Clearest explanation I've seen in a while

  • @xeygarz
    @xeygarz หลายเดือนก่อน +1

    I honestly had such a hard time understanding generics and how they differed from explicitly declaring your types. Your emphasis on generics defining *relationships* finally made everything click for me. Thank you for explaining with all the examples!!

  • @davidgibradze9692
    @davidgibradze9692 2 หลายเดือนก่อน +2

    Your lessons are great and easy to understand for me, thnx , keep going, 👍👍✅🚀

  • @MrBrandenS
    @MrBrandenS ปีที่แล้ว +11

    Wow this video shed a ton of light on some of the confusing pieces around generics for me. The content was so well put together and with the real life example with usages in react itself it really drove the point home from your early examples of generic benefits and when ti use them. Amazing way to teach these concepts. Thanks! Subscribed.

  • @xReDxTuRtLeZx
    @xReDxTuRtLeZx ปีที่แล้ว +8

    thanks for the clarity. you are great at explaining concepts, your vids have objectively made me better at TS and feels great when i manage to remember parts of vids when i encounter scenarios on my projects

  • @IrfanIdris
    @IrfanIdris ปีที่แล้ว +7

    I never realised generics are that simple to explain. Simply great! 👍🏽

  • @MsFunny920
    @MsFunny920 3 หลายเดือนก่อน +2

    Thanks for the best tutorial on generics I've ever found 🤗

  • @ally2502
    @ally2502 8 วันที่ผ่านมา +1

    The relationship tip was all I need to understand the generics! thanks mn

  • @fluntimes
    @fluntimes 10 หลายเดือนก่อน +1

    I agree, this is the best explanation of generics I've encountered. Makes them seem easy, so your video description is on point!

  • @Bangladesh689
    @Bangladesh689 2 หลายเดือนก่อน +1

    This is the best video I've seen about generics.

  • @lil10dot
    @lil10dot ปีที่แล้ว +1

    the way you explain is so clean and concise

  • @ALI-se4ph
    @ALI-se4ph ปีที่แล้ว +1

    your channel is great for junior devs who already know javascript and got job but they need more tricks and knowledge to become a better developer

  • @sofianesaid226
    @sofianesaid226 7 หลายเดือนก่อน +1

    easier than I thought now after watching your video, thank you very much!

  • @xi_red4936
    @xi_red4936 ปีที่แล้ว +2

    This is hands down the best explanation I've ever seen on type Generics. Thank you soo much!

  • @patriciogesualdi7472
    @patriciogesualdi7472 11 หลายเดือนก่อน +2

    I really like the emphasis on the relationship aspect, great video!

  • @wellswatti
    @wellswatti ปีที่แล้ว +7

    "Hopefully this helps you out a little bit with generics". No sir! This helped me out a ton!

  • @uvaishassan
    @uvaishassan ปีที่แล้ว +3

    This is the best video on generics I have watched so far. Was really struggling with understanding generics but this helped a lot. Explaining in terms of relationship between arguments and return type was brilliant

    • @ardianhotii
      @ardianhotii ปีที่แล้ว +1

      I think the same too , best video for generics , again thank you so much @ByteGrag for these awesome videos

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว

      Great to hear!

  • @TieshaOnishea
    @TieshaOnishea หลายเดือนก่อน +1

    Your videos are REALLY helpful, thank you so much. Thanks for the best tutorial on generics I've ever found .

    • @TieshaOnishea
      @TieshaOnishea หลายเดือนก่อน

      I was avoiding generics for a while for no reason, now, finally I will avoid it with a reason

  • @raheelafzal5406
    @raheelafzal5406 ปีที่แล้ว +1

    it was the best of the best explanation i have seen. did not understand the generics, but now it all making sense. HUGE THANKS BRO

  • @Dan-p7f
    @Dan-p7f ปีที่แล้ว +1

    You totally nailed it! I've read docs couple times and yet still didn't get full understanding, but now... thank you man!

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว

      Great to hear! :)

    • @Dan-p7f
      @Dan-p7f ปีที่แล้ว +1

      @@ByteGrad great explanation, keep up the good work

  • @pastuh
    @pastuh ปีที่แล้ว +3

    If the React/Next.js course were explained like this, it would be amazing.

  • @RegisZaleman
    @RegisZaleman ปีที่แล้ว +1

    Well done. It is one of the best explanations of generics I have heard. From super simple to using it in React. Really good. Got my sub!

  • @mkaufmandev
    @mkaufmandev 8 หลายเดือนก่อน +1

    Excellent tutorial packed with valuable information and reasoning.

  • @saiphaneeshk.h.5482
    @saiphaneeshk.h.5482 ปีที่แล้ว +2

    Damn, it feels difficult but you can no where find these kind of basic knowledge which you'll only get from experience.
    Thanks allot.

  • @sarowarhosen003
    @sarowarhosen003 ปีที่แล้ว +1

    . i had many confusion about ts Generics . this tutorial is very helpful for me thank you so much , , now i have clear understand

  • @mohamed_mahran
    @mohamed_mahran 11 หลายเดือนก่อน +1

    Thank you mate!
    The video was on point. Finally I got a understanding in generics.

  • @cypherop2608
    @cypherop2608 10 หลายเดือนก่อน +1

    best explanation on generics so far

  • @nurlanshukurov3864
    @nurlanshukurov3864 ปีที่แล้ว +1

    This is the best Ts generics video I've seen so far. Please, make video about mapped types and keyof keyword also. 👑

  • @heitorpaulo5403
    @heitorpaulo5403 ปีที่แล้ว +1

    Wow! Finally...The relationship tip was the key to understand generics for me.

  • @tblancog
    @tblancog ปีที่แล้ว +1

    I really liked the way you explain such a complex topic like this one, you got a new subscriber. Thanks!

  • @sakarsr
    @sakarsr ปีที่แล้ว +1

    Neat explanation of Typescript Generics. Thank you for your time, have good health and a nice day.

  • @PaulnJenna
    @PaulnJenna 11 หลายเดือนก่อน +1

    Amazing! I was confused before watching this. Great explanation!!

  • @ethaneth6481
    @ethaneth6481 ปีที่แล้ว

    In practice defining theme just as a string makes more sense, but I got your point, good tutorial

  • @shashanktiwari8511
    @shashanktiwari8511 7 หลายเดือนก่อน +1

    Excellent example, and i want to know what is this VS extension that is giving suggestions for auto code complete

  • @stratuspei9405
    @stratuspei9405 6 หลายเดือนก่อน

    Why is the type parameter ( "") after the function name or type name necessary? I'm guessing it's just for better performance of the TS compiler.
    It seems the input parameter type(s) (including the sequence in which they appear) and the output type are sufficient information to determine the relationships that need to be codified.
    I'm grateful for your video. The statement that "generics are specifications of codifying relationships between parameter and output types" is excellent and did make it easy to understand generics.

  • @grottogg4758
    @grottogg4758 ปีที่แล้ว +2

    Thanks for all your hard work, extremely helpful teacher!

  • @attilagyen1446
    @attilagyen1446 ปีที่แล้ว

    You can make it more clear when you leave out the { } and make the convertToArray as a one-liner.
    const convertToArray = (input: T) => [input];

    • @Blast-Forward
      @Blast-Forward ปีที่แล้ว

      Just remember that it won't get hoisted.

  • @adhy612000151
    @adhy612000151 6 หลายเดือนก่อน +1

    Thanks For your explanation about Generic, Wesley!!!! Great tutorial!

  • @AlexShemwell
    @AlexShemwell ปีที่แล้ว +1

    This was such a good explanation. I was always wary of generics, but no longer!

  • @gosnooky
    @gosnooky ปีที่แล้ว +3

    Best convention for type parameters:
    T - type
    U - second type
    E - element
    R - return type
    K - key
    V - value
    P - property
    I - input
    O - output

    • @Blast-Forward
      @Blast-Forward ปีที่แล้ว

      Do we have a lack of memory or why the abbreviations? 😅
      If it's just 1 type argument I would stay with T, but with multiple it's better to use a descriptive name.

    • @gosnooky
      @gosnooky ปีที่แล้ว

      @@Blast-Forward Admittedly, it's a convention carried over from the Java days, but I do like single letter generics - it's easy to discriminate between them and all the other symbol potpourri that comes with static typing, and the letter helps give context to the value's role in the operation.

    • @dealloc
      @dealloc ปีที่แล้ว

      @@gosnooky But not so simple when you then have to use them. Requires you to look up what the they even do-and the definition doesn't tell you right away all the time, so you end up digging through the entire library. You could essentially name your arguments a single letter as well. Not all conventions are good conventions.

    • @gosnooky
      @gosnooky ปีที่แล้ว

      @@dealloc agree to disagree.

  • @Salah-YT
    @Salah-YT ปีที่แล้ว +2

    thank you so much

  • @seelvek6550
    @seelvek6550 3 หลายเดือนก่อน +1

    Thanks Wesley! Great as always!

  • @Ahmed-fq3kz
    @Ahmed-fq3kz 10 หลายเดือนก่อน +1

    Wow, very clear and to the point

  • @gregplittjunior8313
    @gregplittjunior8313 ปีที่แล้ว +1

    Kind of clear explanation, bravo 👏

  • @ryanwoods3333
    @ryanwoods3333 ปีที่แล้ว +1

    really enjoy the typescript/react content thank you!

  • @Harduex
    @Harduex ปีที่แล้ว +1

    Very clean and comprehensive tutorial, keep up the good work 🙌

  • @HeyNoah
    @HeyNoah ปีที่แล้ว +1

    Awesome tutorial!! Super easy to follow! Thanks a mill!

  • @Redyf
    @Redyf 8 หลายเดือนก่อน +1

    Your videos are REALLY helpful, thank you so much

  • @pasanflo
    @pasanflo ปีที่แล้ว +1

    Good example, thanks!

  • @laputafelix
    @laputafelix ปีที่แล้ว +1

    Again, another extremely precise video to me

  • @mervinmarias9283
    @mervinmarias9283 ปีที่แล้ว +1

    I don't even use TypeScript, but after this video I actually understand how to use generics.

  • @shivanshpatel4072
    @shivanshpatel4072 11 หลายเดือนก่อน +1

    Awesome video you make this concepts really easy to understand ❤

  • @grzegorzpaprzycki2547
    @grzegorzpaprzycki2547 ปีที่แล้ว +1

    You explain hard topics very clearly. Keep going like that ❤

  • @miksica
    @miksica 11 หลายเดือนก่อน +1

    Pure gold, and thank you!

  • @vpdexx
    @vpdexx ปีที่แล้ว +2

    Great! Just one question: what's the point of having a generic since you are extending it from something else (React.ReactNode in your example)? You do that just for relationships between params and return value or am I missing something? Thank you, keep it up!

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว +2

      Yep, just to codify that relationship between the 2 props

  • @MahdiyarRezaei-o7i
    @MahdiyarRezaei-o7i 16 วันที่ผ่านมา +1

    well done , keep going sir !

  • @reazon7
    @reazon7 4 หลายเดือนก่อน +1

    Thx you, really great explanation.

  • @mr.javascript1320
    @mr.javascript1320 ปีที่แล้ว +1

    Amamzing explanation !!!! loved it !!!!

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว

      Glad you liked it!

  • @dominikrodler8010
    @dominikrodler8010 7 หลายเดือนก่อน +1

    Excellent presentation

  • @Assassin29
    @Assassin29 ปีที่แล้ว +1

    very easy and cool explanation

  • @ajayrathod7438
    @ajayrathod7438 5 หลายเดือนก่อน

    It was a very nice video thank you.
    What package do u use to get suggestions for your code

  • @scott98390
    @scott98390 ปีที่แล้ว +1

    Is there a way to create extension methods on a Type without running into issues because you extended the .prototype?

  • @maor44
    @maor44 ปีที่แล้ว +1

    Amazing video dude! really helpful!

  • @alenakavyrshyna3916
    @alenakavyrshyna3916 10 หลายเดือนก่อน

    The best video about generics ❤ thanks

  • @junsgk
    @junsgk ปีที่แล้ว +2

    Best best ts teacher on youtube

  • @petleveler8366
    @petleveler8366 6 หลายเดือนก่อน +1

    So much value here!

  • @amirhossein.banaei
    @amirhossein.banaei 9 หลายเดือนก่อน +1

    great explanation. thanks a lot .

  • @123tomani
    @123tomani ปีที่แล้ว +1

    Very well explained 🎉
    Can you also do a video on websockets and best way to implement in micro front end application

  • @pixyoutube538
    @pixyoutube538 ปีที่แล้ว +1

    Great! Your video is very easy to understand

  • @ludwigvillalba1886
    @ludwigvillalba1886 ปีที่แล้ว +1

    Well explained!

  • @alexandrupintilei5657
    @alexandrupintilei5657 ปีที่แล้ว +1

    Awesome video! Thanks!

  • @nathpaiva
    @nathpaiva ปีที่แล้ว +1

    Generic is so cool. Nice video!

  • @danielmdenton
    @danielmdenton ปีที่แล้ว +1

    This video earned a subscription.

  • @mikkun_
    @mikkun_ ปีที่แล้ว +1

    In just 22 minutes, I've learned a lot

  • @Edgar-pu1lc
    @Edgar-pu1lc ปีที่แล้ว +1

    Hello, when will your next js course be ready?

    • @ByteGrad
      @ByteGrad  ปีที่แล้ว +1

      Finishing the last few details. Make sure you’re on the email list :)

  • @fiskryeziu
    @fiskryeziu ปีที่แล้ว +1

    Thank you for the video learned a lot

  • @matan1147
    @matan1147 ปีที่แล้ว +1

    Great video!
    loved your explanations 🔥

  • @huykyoby1059
    @huykyoby1059 ปีที่แล้ว

    Thank you, Can I ask what extension you are using that it suggests when you code?

  • @cubedev4838
    @cubedev4838 11 หลายเดือนก่อน +1

    I love how the way u explain

  • @schintus
    @schintus ปีที่แล้ว +1

    As a C# developer, this might be easier for me to understand up-front than pure JS devs :)

  • @ExiledDelver
    @ExiledDelver 9 หลายเดือนก่อน

    you mentioned not to have "any" in your first example you returned => return [input.toUpperCase()] and said if you have an any this is no good since a number cant use the toUpperCase, wouldnt a generic do identically the same thing? const someFunc = (input:T):T[] => return[input.toUpperCase()] is this not the same as any?

  • @K.Huynh.
    @K.Huynh. 11 หลายเดือนก่อน +1

    thank for sharing! It's new for me! 🌈

  • @derrickcheung919
    @derrickcheung919 11 หลายเดือนก่อน

    Generics isn't bad in other languages , but I found it quite daunting in typescript

  • @SimPwear84
    @SimPwear84 ปีที่แล้ว

    Very cool video! I found your channel today and subbed for more content

  • @serhiityshchenko4006
    @serhiityshchenko4006 ปีที่แล้ว +1

    Great video. Thanks!

  • @__mac
    @__mac ปีที่แล้ว +1

    This helped alot!

  • @fonshiynwatobi4675
    @fonshiynwatobi4675 ปีที่แล้ว

    This masterpiece is 10 years old

  • @markmuthii
    @markmuthii ปีที่แล้ว +1

    First time here, and from this one video, I can tell I've landed on a goldmine.

  • @thimerlanmatyakubov8940
    @thimerlanmatyakubov8940 ปีที่แล้ว +1

    THATS COOOOOOOOOOOOOOOOOOOOOOOOOLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

  • @kashmirtechtv2948
    @kashmirtechtv2948 15 วันที่ผ่านมา

    Can't we use PropsWithChildren for props? 11:54

  • @md.asifal-mahmud5952
    @md.asifal-mahmud5952 ปีที่แล้ว +1

    Awesome, Thanks a lot.

  • @bokisa007
    @bokisa007 ปีที่แล้ว +1

    great tutorial, part with themes reminded me why I actually hate typescript :D

  • @meal_team_six
    @meal_team_six 9 หลายเดือนก่อน +1

    Very helpful!

  • @GooseGumlizzard
    @GooseGumlizzard 8 หลายเดือนก่อน +1

    this is great, thank you