TypeScript: How and Why You Should Learn It

I recently had a virtual coffee chat with a Software Engineer who told me that the most important new thing to learn when looking for your first post-bootcamp job would be TypeScript. I’d seen it mentioned many times but wasn’t quite sure what it was besides being a typed form of JavaScript — whatever that meant.

What is it?

TypeScript was created in 2012 by Microsoft Technical Fellow, Anders Hejlsberg (who also created C#). JavaScript was never intended to function on large-scale apps and it’s weaknesses can easily be exaggerated at scale. TypeScript is a subset of JavaScript which adds the ability to make JavaScript into a ‘static typing’ language. Programming languages fall into two main types: dynamic typed languages like JavaScript or Python where the types of data is not explicitly declared. And typed languages like Java where it is.

The main benefits of this are that it allows you to check your code for errors as you go, as opposed to waiting until runtime for the code to compile. This can help eliminate errors on the fly, rather than seeing the problem outputted and having to go back and debug.

But don’t take my word for it. See the full 50 minute video of Hejlsberg introducing the world to TypeScript directly. It is extremely informative and Hejlsberg gives a thorough yet lucid explanation.

Why Should You Use it?

As the tagline states: TypeScript is JavaScript that scales.

TypeScript was explicitly created to enable larger JavaScript applications to run better and smoother at scale. Therefore, if you are working on a large project in JavaScript — it will be much easier for both you and your users if you write it in TypeScript.

The inverse is also true, if your project is small and simple. The added benefits TypeScript brings are no longer so valid and instead the slightly longer time it takes to add up and run all the types in TypeScript can actually make your project run a little less efficiently.

So if you are working on a large-scale application, the chances are you should use TS>JS. This is especially true because if you already feel comfortable and confident with JS, TypeScript is very easy to learn and doesn’t require wholesale changes. Below are some excellent resources to learn TypeScript so you can use it yourself.

How To Learn It

After watching the video above of Anders Hjelberg introducing TypeScript the best thing to do is read through the official docs. In particular, the ‘TypeScript in 5 minutes’ section and the tutorials.

Another good resource for the theory is the tutorial from TutorialsPoint. It is very word-heavy and lacking fancy graphics but it is informative and clear. These should give you a good base for the theory and how things operate.

For practice writing:

There is an excellent Scrimba by Dylan Israel which goes through how to start building apps.

As well as the free Codecademy course on TypeScript which is less accessible than the Scrimba but still very useful.

With these resources you should have a good understanding of how TypeScript works, why it would work for you and how to make it work for your apps.

Happy Typing!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store