Why YOU should migrate to TypeScript
TypeScript is now the most popular language on GitHub. Learn why everyone's going mad for it.
00:00 Intro
00:29 Undefined is not a function
01:44 Securing your own code
03:07 Libraries
04:38 Third-party API's
05:46 Get out of jail free
Become a TypeScript Wizard with Matt's upcoming TypeScript Course:
www.totaltypescript.com/
Follow Matt on Twitter
/ mattpocockuk
Пікірлер: 55
I'll show this video to my team.
@mattpocockuk
Жыл бұрын
Yesssss, join the army
I absolutely love TypeScript. Sure i have to type more but that is totally fine with me as long as i know the type of the parameters that I have to pass to a function and the returned value. Your videos on what one can do with generics are awesome 😀
@mattpocockuk
Жыл бұрын
Thanks pal!
5 years working with TypeScript and I don't see why others dislike it. Always good to have some extra checking and helpers.
This comment is to show engagement to the almighty algorithm. Great video and I look forward to more.
@mattpocockuk
Жыл бұрын
Thank you for your engagement!
Hi Matt Love the way you teach. Is your course coming this year and how long will it be😁can't wait. Love from Switzerland
Love ya work Matt
I love to see TS with React, Solid or any JS framework type save, This content is awesome!
@harrytsang1501
Жыл бұрын
Typescript is still not foolproof. const objects can still be mutated, and that makes a lot of invisible bugs especially when you are working with legacy code
@ogreeni
Жыл бұрын
@@harrytsang1501 const objects should be mutated. Objects are reference types, and the only thing const guarantees is that the reference will not change. Same with arrays.
I'm going to be trying to convince my company to switch to TS soon. Thanks for doing videos like this.
I just learned Typescript 2 months recently. From what I learned form it, it made my coding much more fast and predictable especially when I need to know all the possible methods a an object.
Loved the 💢 expressions
@mattpocockuk
Жыл бұрын
My speciality
Please can you do a video and deconstruct how the types for Express' app.get parses the path params?
It's been a long time Matt.
@mattpocockuk
Жыл бұрын
👋
Hi Matt, I am only a beginner in learning Javascript and React, I watch and enjoy your videos as i do find them interesting and you do explain concepts very well. However I get the basics of Typescript like declaring number type in parameters but I have watched your videos and there are things like keyof, extends, T, K, key, generics. it is hard enough to learn Javascript on it's own let alone with all the complicated extra boilerplate
@mattpocockuk
Жыл бұрын
The amazing thing about TS is that you can be INCREDIBLY productive with it while only knowing 5% of its feature set. If the complicated stuff doesn't interest you, you don't need to learn it. What I personally found was knowing the advanced stuff made me more able to create better API's for my team members, so advanced me very quickly to being a senior/lead TS dev. But if your focus is on shipping (as it should be when starting out) then just focus on the basics.
Is it possible to get that type inference from the route string when separating the callback function from the router function?
how would you recommend learning typescript and learning it well, what resources?
ive been using typescript for 1 year and i loved it. i got my first job last week as a backend dev but they use python and golang. so now i have to move away FROM typescript, and focus to learn those languages instead. feel a little sad but at least i get paid now 😅, anyway man, i love ur typescript stuff, it was really helpful when i was a beginner
@mattpocockuk
Жыл бұрын
That's great to hear pal. I'm sure TypeScript will call you back when it's time
I started using typeScript 3 months ago
In my experience I was really scared to try typescript. But it's just the matter of one project after that there is no looking back to JS....♥️♥️
Hey Matt, any particular advice on when to use a text enum vs a union of strings? I like the idea of using an enum where if a value ever needs to change, you don't have to worry about checking for all occurrences, but I find it ends up being a real annoyance when trying to write a type guard at times, where I have to write type predicate functions that confirm it as a member of the enum, rather than TypeScript being able to infer that it's in the enum by matching the strings.
@mattpocockuk
Жыл бұрын
I pretty much always go for string unions. Much easier to deal with and no need to import.
@Edward0TheGreat
Жыл бұрын
@@mattpocockuk Thanks so much for responding! Is this one of those situations where you feel there is a valid use-case for using enum, but simply that you don't run into it often? Or do you tend to think that's your preferred method in every case?
@mattpocockuk
Жыл бұрын
@@Edward0TheGreat My default position is to not use enums, I generally only use them when I really really feel the need (which is rare)
0:01 Is Wizardry a good thing? Whether in TypeScript or any other kind of programming. Genuinely curious. Because "magic" has been one of the most frequent complaints hurled against programming languages and frameworks for years.
@mattpocockuk
Жыл бұрын
I'm going more for the _feeling_ of being a wizard, like you have total control and everything feels easy.
@magne6049
Жыл бұрын
@@mattpocockuk can't escape the fact that a lot of what you do is also TS wizardry ;-)
The only time I get errors with typescript is when a package is compiled with the wrong importing implementatiom
I was doing a React test in JS and was a nightmare because typing, I lost 1 hour looking through the src just to understand the fields of an object.
@mattpocockuk
Жыл бұрын
That's interesting. I find the TS types with React really nice, and combine them all the time in prod. Do you remember specifically which error you came up against?
@neociber24
Жыл бұрын
@@mattpocockuk The test required to fix methods of a reducer (using redux/toolkit). I made a lot of silly type errors: - Wrongly copied an array using object { ...array }. - I forgot about action.payload field - Other is that in some cases some actions had an action.payload.data field which I didn't knew.
What in his VS Code is making the code show up as if its guessing what he's going to type next?
@mattpocockuk
Жыл бұрын
GitHub Copilot
Why YOU should finish your advanced typescript course
@mattpocockuk
Жыл бұрын
All the content is written, just recording it now!
@gubatenkov
Жыл бұрын
@@mattpocockuk we have been waiting for this course for more than 3 months
@mattpocockuk
Жыл бұрын
@@gubatenkov I ain't rushing it!
@gubatenkov
Жыл бұрын
@@mattpocockuk It's okay, we're not rushing you
Ok
🤴
04:38, this is something I struggle to understand when moving onto TypeScript. If I am not in control of the 3rd Party API. What if they suddenly change the response and the hair_color will be of type number? Why should I type the response, if I can't guarantee the response will be of that type. Shouldn't I check it via JS anyway? So you do hair_color: string, but then shouldn't you also do additional checks in your JS code like .. if typeof hair_color === "string" continue, otherwise throw error or something?
@mattpocockuk
Жыл бұрын
Absolutely, you should use Zod in these cases. Zod gives you runtime safety AND type safety.
@alexbechmann594
Жыл бұрын
@@DrWarpMan If they have an Open API spec you can codegen types from it
Typescript is amazing untill autocomplete takes 40 seconds. The type checker is so painfully slow even on smaller projects.
i thought this was going to be about taylor swift from the title :/
na im good