Stack Choices: JavaScript vs TypeScript

As a developer, there are many choices to make when building your next application. The rise of serverless technologies allows developers to build and run applications without thinking about servers and this also allows front-end developers to create full-stack applications and build SAAS web apps.

In Stack Choices, we take a closer look at some technologies that can help us to build these types of applications and try to make a good decision on what to use. This time, let’s take a look at going with plain old JavaScript or the rising star: TypeScript.

What is TypeScript?

TypeScript is an open-source language that builds on JavaScript by adding static type definitions. Types provide a way to describe the shape of an object, providing better documentation, and allowing TypeScript to validate that your code is working correctly.

You can easily use Typescript when starting a new React application by running yarn create react-app my-app --template typescript or work with Angular, which comes with Typescript by default.

How popular is TypeScript?

TypeScript seems to be taking over front-end development. Almost 90% of developers (who filled in the state of js survey) admit they would like to use or learn TypeScript in their next project. Besides that, it's one of the most loved languages, according to the 2019 Developer Survey by Stack Overflow.

My personal experience

I have been working with Typescript full-time for over a year now, and I have experienced the benefits of using TypeScript when working in a team. Something I personally like is, for example, the rich IDE support. I’m using VSCode and it offers features like code navigation, autocompletion, and providing accurate suggestions. You also get feedback while typing like flagging type-related errors as soon as they occur. This can help you write more maintainable code.

Although TypeScript is really good, it’s not perfect. In the beginning, I didn’t like working with TypeScript at all. It requires some time to learn and you need to write more code than with just JavaScript.

Here are, in my opinion, the pros and cons of choosing Typescript for your next project.

Pros for using Typescript

  • It has rich IDE support
  • It has object-oriented programming features
  • It helps to spot bugs early
  • It is used in popular frameworks
  • It’s growing in popularity

Cons for using Typescript

  • Writing more code
  • Takes time to learn
  • Adds complexity

Conclusion

Although TypeScript requires you to write some more code and could take developers some time to learn, it’s benefits outweigh that in my opinion. We also see steady growth in the adoption of the language so I think this is not a hard decision to make. My stack choice: TypeScript.

If you think differently, please try to change my mind! Any other opinions? Leave them in the comments.


If you’re interested in saving time on your next project and skipping implementing authentication, payments, tests, etc. then subscribe here to follow my progress in building the SAAS starter-kit for JavaScript developers. You can also follow me on Twitter, or at www.jakeprins.com.

Stay up to date

Get notified when I publish something new, and unsubscribe at any time.