We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Why TypeScript

TypeScript is a superset of JavaScript, meaning that:

  • All JavaScript code is valid TypeScript code.
  • All TypeScript code is not necessarily valid JavaScript code.

But who tf cares? The real question is, why should I use TypeScript instead of JavaScript? Well, TypeScript is fantastic because it:

  • Catches a ton of bugs and errors at compile time (fact)
  • Makes your code more readable and maintainable (imo)
  • Makes it easier to refactor and scale your codebase (imo)

In short, it adds static typing to JavaScript.

Static vs dynamic typing isn't exactly a settled debate in the programming community, but for me personally, I'll take static over dynamic types any day of the week. I like to hover over variables and see their types, and I like to know that my code doesn't have an entire class of potential bugs before I even run it.

Story Time

TypeScript was developed internally at Microsoft by C# developers (led by Anders Hejlsberg) who wanted static typing in their JavaScript (C# being a statically typed language). It was released to the public in 2012, and while its execution speed isn't necessarily blazingly fast, its meteoric rise in popularity is.

Click to play video

In the video we briefly mention a "linter". A linter is a tool that automatically analyzes your code and warns you about potential errors, style issues, or bad patterns before you run it.