Typescript Generics Tutorial

Поделиться
HTML-код
  • Опубликовано: 25 авг 2019
  • Learn how to use generics in Typescript. I go over how to use them in your React.js code and create your own in functions, interfaces, and jsx.
    #typescript
    Code: github.com/benawad/typescript...

    ----
    Follow me online: voidpet.com/benawad
    #benawad
  • НаукаНаука

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

  • @sanjarmirakhmedov4016
    @sanjarmirakhmedov4016 4 года назад +199

    One of the best tutorials on Generics I have ever watched. Thank you Ben!

    • @edwingarcia5043
      @edwingarcia5043 4 года назад +1

      Not for beginner though, while I was watching this I could see the useful parts, but some times I just didn't get it (most parts in React part) ... I will read and fully undertand their full important, I won't give up.

    • @georgestan9563
      @georgestan9563 3 года назад +7

      @@edwingarcia5043 The generics explanation was very good, you're probably lacking other information needed to understand the code, I recommend revisiting more basic concepts of programming before jumping into this.

    • @foobars3816
      @foobars3816 3 года назад

      @@georgestan9563 No it was clearly noting to do with the basics of programming and more about him not understanding how React and Formik works. I think he pretty clearly said that in his comment. Which BTW is quite irrelevant for him unless he want's to use either of those, this was just more of showing a practical example for people who are familiar with React and Formik.

    • @codeaperture
      @codeaperture 3 года назад +2

      He's an asset in the JavaScript community

    • @youngun550
      @youngun550 Год назад

      Was about to say the same thing. No nonsense, really clear and focused!

  • @glzr_io
    @glzr_io 4 года назад +25

    Mad props for making this. Found that the docs were pretty lacking when it came to generics and this really cleared things up. Been using TS for a while now but still found this super helpful

  • @kps2642
    @kps2642 4 года назад +61

    This video legit dropped right when I was reading Typescript docs

  • @swyxTV
    @swyxTV 4 года назад +51

    to return the tuple you can also assert `as const` at the end of that function

    • @selftaughtcodelab
      @selftaughtcodelab 3 года назад +3

      Yes, that might be another way but the disadvantage will be that typescript will not allowed to push more values in returned array as we declare it as ready-only via const.

    • @jivkojelev3744
      @jivkojelev3744 3 года назад

      Or u can use keyword readonly.

  • @Ko0lHaNDLuKex
    @Ko0lHaNDLuKex 4 года назад +10

    Really good as always, Ben! I've been using TypeScript for a while now, but I still learnt a lot from this video! Thank you.

  • @nicholasroman8071
    @nicholasroman8071 2 года назад +1

    Thank you Mr. Awad for the short, concise, and elegant explanation of generics.

  • @mccall7122
    @mccall7122 2 года назад +4

    I've been youtubing and googling for over an hour trying to wrap my head around generics. The first 5 minutes of your video did a better job than all the other videos and articles and documentation. Kudos, and thanks!

  • @Ascended23
    @Ascended23 4 года назад

    Great video! I’m so glad that you used example functions other than an “identity” function that just returns the argument. It’s much easier to understand when you can infer how the thing it’s doing is something that could be useful.

  • @yowchun95
    @yowchun95 4 года назад

    Thank you so much for this tutorial, i have been scratching my head trying to figure out how generics work in Typescript, and this video pretty much cleared it up for me.

  • @ikezedev
    @ikezedev 4 года назад +5

    I love this.... Just started rewriting an open source library of mine in typescript and this was just what I needed. Thanks @Ben Awad

  • @cesarbuenrostro622
    @cesarbuenrostro622 4 года назад +1

    Thanks dude, I'm studying for a week, but this video clears all the doubts, you're rock!

  • @yuri4n
    @yuri4n 4 года назад +2

    The video was really quickly but you give the concepts clearly and concise, thanks, man

  • @rafarovina
    @rafarovina 3 года назад +33

    I can't count how many times I've use a Ben's video to settle a discussion :D Thank you for the all awesome content! Inspiring programming style, using TS at it's best, always!

  • @paulina7497
    @paulina7497 Год назад

    I read few blog posts about generics and thought I am too stupid for that but your explanation made me understand everything I struggled with before. Thank you

  • @Cognitoman
    @Cognitoman 4 года назад +16

    By the way ur killing it my dude. Keep grinding your in your way

  • @dawid_dahl
    @dawid_dahl 4 года назад +2

    You have the best tutorials on RUclips. Thanks so much!

  • @kallekula9202
    @kallekula9202 3 года назад +1

    Your videos are always great. Thanks Ben. You explain everything really well.

  • @NatashaUrbancic
    @NatashaUrbancic 2 года назад +1

    This made generics so much easier to understand! Thanks for making this video 👍

  • @kayodeayelegun6279
    @kayodeayelegun6279 3 года назад

    Yo!!! This is the best explanation on generics. I especially love the jsx example. Awesome stuff 🔥🔥

  • @Middollo
    @Middollo 4 года назад

    Best generics explanation i found on youtube so far. Thanks.

  • @selftaughtcodelab
    @selftaughtcodelab 3 года назад

    Can't expect better explanation than this. Thanks Ben.

  • @lastmaj
    @lastmaj 3 года назад

    I started reading about typescript today and this is better than the docs. thank you

  • @yashrahurikar7533
    @yashrahurikar7533 4 года назад +1

    Thanks Ben,
    Please keep making videos like these on Typescript

  • @Bostologia
    @Bostologia Год назад

    - The best generics tutorial I've ever watched!

  • @thisisgksingh
    @thisisgksingh 2 года назад +1

    Ben Awad the boss of coding on youtube and some of the best explanations that I have seen.

  • @rakeshjoshi2306
    @rakeshjoshi2306 4 года назад +1

    This video is really great to start with typescript generics

  • @pyroghost11
    @pyroghost11 4 года назад +1

    Thanks Ben for the clear explanation, I adore your videos and always recommend it to people at my company!

    • @bawad
      @bawad  4 года назад +1

      thanks, that's awesome!

  • @ayomikuolatunji1580
    @ayomikuolatunji1580 Год назад +1

    This is the best generics tutorial on RUclips

  • @malikaremu2344
    @malikaremu2344 2 года назад

    this the best typescript tutorial video i have ever watched, thank you

  • @xyz-ey7ul
    @xyz-ey7ul Год назад

    dopest video ever. i always come to this when i forget generics. this video alone is 80% typescript

  • @yetanotherchannelyac1434
    @yetanotherchannelyac1434 3 года назад

    This was an amazing exposition of generics!

  • @vanibron
    @vanibron 3 года назад

    Huge thanks! Great explanation, Ben.

  • @whoamiwhoru
    @whoamiwhoru 3 года назад +1

    This tutorial cannot be free! Thank you so much :)

  • @maximbazadji4895
    @maximbazadji4895 3 года назад

    Thank you, Ben
    Your tutorials are great

  • @dgabrielm
    @dgabrielm Год назад

    absolutely brilliant tutorial, thanks!

  • @dimavoitenko2386
    @dimavoitenko2386 4 года назад +1

    Thank you! Really clear explanation.

  • @MohammadBarghamadii
    @MohammadBarghamadii Год назад

    Thank you so much, for your great Generics tutorial.

  • @mayur9876
    @mayur9876 4 года назад

    This helped me alot. Thanks Ben.

  • @infiniteeyelashes6729
    @infiniteeyelashes6729 4 года назад +2

    Excellent video, learned a lot.

  • @PushpendraKrSingh
    @PushpendraKrSingh 2 года назад

    This is really nice tutorial, keep it up Ben!

  • @bassam.2023
    @bassam.2023 Год назад

    Finally I understand generics. Thanks!

  • @navazalani6941
    @navazalani6941 2 года назад +11

    At 19:37, it seems to be some sort of parsing error which mistakes for JSX instead of a TS generic. You don't necessarily have to "extend" something to get the parser to realise it's a TS generic -- a simple would work as well.
    Great video, Ben!

    • @sayandcode
      @sayandcode Год назад

      I was running into the exact same error at 4:16 too! Thanks man

    • @uditgupta3429
      @uditgupta3429 Год назад

      Thanks Man

  • @arsamsarabi
    @arsamsarabi 4 года назад

    Thanks for the great videos. Keep up the good work 👍🏻

  • @raghavsurya4755
    @raghavsurya4755 3 года назад

    Man, this is amazing stuff! Thank you bro

  • @_oo.monkeypox.oo_3344
    @_oo.monkeypox.oo_3344 2 года назад

    Great way to explain things. Thanks Ben

  • @zuz2511
    @zuz2511 Год назад

    Thanks bro. I was look for interfaces that implement generics just right now

  • @none_the_less
    @none_the_less 4 года назад

    Great content. Keep up with the good work.

  • @julianklumpers
    @julianklumpers 4 года назад

    Awesome video! Helped me alot, thanks!

  • @EddyVinck
    @EddyVinck 4 года назад +4

    Great video. Really liked how you included some React as well.

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

    Still relevant in 2024, thanks a lot Ben :)

  • @kld0093
    @kld0093 4 года назад +1

    this is why i love typescript

  • @charlietaylor9266
    @charlietaylor9266 4 года назад

    nice one! just what i was looking for.

  • @vim55k
    @vim55k 4 года назад

    Thanks. 3 new uses for generics

  • @minhcuongle6660
    @minhcuongle6660 4 года назад

    This's a awesome tutorial

  • @edwardjr.5688
    @edwardjr.5688 3 года назад

    Thanks man, it was clear and concise.

  • @JonathanRintala
    @JonathanRintala 4 года назад +1

    Awesome tutorial 🔥

  • @Zeuchon
    @Zeuchon Год назад

    Very good intro to typescript!

  • @vuvoth
    @vuvoth 2 года назад

    Thank for the video! Very useful!

  • @NOTHING-en2ue
    @NOTHING-en2ue 11 месяцев назад

    very great tutorial, now i understand Generics ❤

  • @bdk9830
    @bdk9830 2 года назад

    Thank you Ben! Now I can refactor my project better.

  • @creativedeveloper6921
    @creativedeveloper6921 4 года назад

    You are awesome Ben!!!!!! 🙌

  • @johanneswijaya5384
    @johanneswijaya5384 2 года назад

    Thanks man, this really helpful!

  • @gerryramosftw
    @gerryramosftw Год назад

    This was an awesome video sir. Thank you for this

  • @samplesample9714
    @samplesample9714 2 года назад

    Thanks for this video it really help and simple to understand typescript generics

  • @AltairLink
    @AltairLink 3 года назад

    Great tut! Thank you!

  • @Max-bh8tg
    @Max-bh8tg 3 года назад

    Great video Ben 👍

  • @ARMALON87
    @ARMALON87 Месяц назад

    Love it, thank you, man!👍

  • @jitujahagirdar613
    @jitujahagirdar613 Год назад

    really good explain Typescript Generics..!👍
    As a developer we always look for short video but better to explain. you did good job to explain and that what i like about this video.

  • @vig221
    @vig221 2 года назад

    I just love that you're using Vim.

  • @4dakto
    @4dakto 4 года назад

    thank you. this video is very helpful.

  • @alinawaz4034
    @alinawaz4034 4 года назад

    Amazing work man thanks

  • @datasciencetoday7127
    @datasciencetoday7127 3 года назад

    i miss these kind of videos @Ben

  • @problemno6943
    @problemno6943 2 года назад

    thx ! had been learned a lot

  • @CoryTheSimmons
    @CoryTheSimmons 4 года назад

    Just got into Typescript pretty hard about a month ago. Was always confused what the

  • @ridl27
    @ridl27 4 года назад

    useful and clear tutorial, thx =)

  • @Rudenich911
    @Rudenich911 3 года назад

    Thanks, great explanation

  • @Scripterrific
    @Scripterrific 4 года назад

    Do you have a video explaining why we must use “as” to assert types instead of the form in JSX? I noticed this mentioned in the typescript documentation, but it wasn’t clearly explained what was meant by it.

  • @LeonardoRivaldo
    @LeonardoRivaldo 4 года назад

    I was looking for something more deep and complex about generics, like type creation based on objects or enums or any more complex examples, since I m a experiment programer in TS, but it has some interesting concepts, coodles!

    • @bawad
      @bawad  4 года назад

      I'll have to do a more advanced tut at some point :)

  • @umarjaved1489
    @umarjaved1489 3 года назад +1

    Ben, to get the most out of your videos, one must already be familiar with the concept

  • @damdo808
    @damdo808 Год назад

    Aaaand... that's it? xD Man, I was watching others trying to explain it like it was some sort of a rocket science. Thanks!

  • @maxtayebwa8987
    @maxtayebwa8987 4 года назад

    Thanks Ben!

  • @fille.imgnry
    @fille.imgnry 4 года назад

    Would love to see a video on using Typescript with Svelte 🤩

  • @softwareadministrato
    @softwareadministrato 3 года назад

    Awesome video!

  • @user-sm3rx2uw7r
    @user-sm3rx2uw7r 11 месяцев назад

    Very nice and helpful

  • @YaserAz
    @YaserAz 2 года назад

    This is awesome.

  • @rezakajbaf6702
    @rezakajbaf6702 2 года назад

    Great video.

  • @amaanimtiyaz
    @amaanimtiyaz 2 года назад

    Nice, Really Good

  • @aprilmintacpineda2713
    @aprilmintacpineda2713 3 года назад

    Loved it.

  • @ibrahimnazari8376
    @ibrahimnazari8376 3 года назад

    thanks great tutorial

  • @JonsonNcube
    @JonsonNcube 2 года назад

    WOW!!! I could kiss my screen right now!!
    Ben you beautiful mind you!! Thank you, I understand Generics now!

  • @brijspy
    @brijspy Год назад

    This will take some time to digest.

  • @elusariosinnombre2058
    @elusariosinnombre2058 Год назад

    This is a good ass tutorial!

  • @soroushrustrow9567
    @soroushrustrow9567 2 года назад

    awesome. thank you :)

  • @arpitbharti6245
    @arpitbharti6245 4 года назад +1

    At 19:43 Line-18, you don't _have_ to write ** instead write it as ** notice the comma after T

  • @hiradsoleimani2331
    @hiradsoleimani2331 Год назад

    Greate video thanks👍

  • @avimehenwal
    @avimehenwal 3 года назад

    Wow! amazing ... I just realized its Parametric polymorphism

  • @sammmba
    @sammmba 4 года назад

    thank you!!

  • @dapoadedire
    @dapoadedire Год назад

    Thanks for thie video.

  • @PetarVukmanovic
    @PetarVukmanovic Год назад

    Holy cow bro. Noice. Ty.

  • @__kawaii
    @__kawaii Год назад

    Отличное видео, спасибо!