No look I get it, I know I know, I'm late on this one.
Typescript has been around for ages now and I'm just now learning it. As always, I'm behind the curve on a lot of this stuff. I'm working on it, okay?
This post is going to be all about why I'm learning Typescript, what Typescript is and why it's become A Big ThingTM in the web development world.
Wait what the hell is Typescript?
Yeah, that's fair, I'm with you.
Think of it this way: I have a function that reaches out to a web server, grabs some JSON, pulls out a field and puts it in a variable that is then returned to your main function, which concatenates that string (using the "+" operator) with another string and prints it. This works fine for a while, until, for whatever reason, the web server decides to return an integer in that JSON field. Now, since you're using a loosely-typed language, that error is going to get passed downstream when your code now is trying to add an integer ot a string instead of concatenating. A strictly-typed language will catch it when you try to assign an integer to a string-type variable, which will make the problem much easier to find and debug.
Why am I learning Typescript?
Honestly this is a fairly uninteresting answer: I have a project I'm working on that requires it. 🤷♀
I also know that it's an important asset for a full-stack web developer to learn, or at least to be familiar with. If there's a new tech stack, new buzz word or a new library, it's always good to at least initially check it out and be vaguely familiar with it, in my opinion, though this is something that I'm very obviously behind on. It's why I'm playing catch-up now, basically to catch up with the curve on a lot of technologies and environments so that I can stay up-to-par at the very least with other full-stack developers.
Typescript also just seems like an objectively useful thing to learn as well, for reasons I'll go into below.
Why should you learn Typescript?
I say this as someone who pretty much exclusively has written in loosely-typed languages, they cause more bugs. Expecting a string variable returned with no explicit typing makes it fairly easy to accidentally code in surprise edge cases where an integer is returned, which can bork things down the road when you're trying to concatenate the returned string with another string but instead you end up trying to add a string to an integer.