My Notebook

TypeScript: Yay or Nay?

2021-02-24 · 2 min readMy thoughts on whether or not to use typescript, and if its an all around good language.Just a few weeks ago, I started to use typescript a lot more in my projects, trying it out in a multitude of applications. After using it in and out, and trying it on a few projects, I think I've come to a conclusion on whether or not its a good language. But first defining what I think a good language is. A good language needs to be intuitive, easy to use, easy to debug, and reasonably performant. In my experience, typescript seems to check all those boxes.Starting with my first qualm with javascript that typescript seems to fix is undefined errors. These errors happen ALL THE TIME, if you're a javascript developer, where you either have to log an object to tell its properties, or rely on your memory to spell everything out correctly. Even with that, sometimes the values might not be there, and be very hard to catch, with an object with an undefined key returning undefined. Typescript gives an elegant typing system that seems to mesh really nicely with the javascript ecosystem, and makes knowing the type of every variable very easy. The best part I find, is that it allows degrees of flexibility, so that everything doesn't need to be statically typed at all. You can include snippets of JS with TS and have everything mesh really easily. The typing is relatively similar to rust typings with angle brackets, which helps a lot when switching over. Overall the debugging experience is a lot more pleasant, where I find a much larger ratio of code to debugging than before.The second main reason for loving typescript other than just debugging, is auto complete, which comes from the implications of having types in a language. This is super helpful as it speeds up the need of having to check the documentation time and time again, just to look for that one method that you need. Typescript defines everything very explicitly, so you can look through the methods and properties inside the object with ease, and almost never have to deal with the maze of checking which class you have stored in a variable and determining which methods are available.Overall, I find typescript quite enjoyable, and can't wait to use it in my next projects! If you want to check out an example of one of my projects I'm writing in typescript, you can take a look at the discord bot I'm building for AngelHacks!
Thanks for reading! Liked the story? Click the heart
Created with ☕ by @neelr