DevBuilt

Why we chose TypeScript over JavaScript

Tim E February 2024

Lines of code

Our team started off as a pretty standard split between frontend JavaScript developers and backend PHP developers.

In the early stages of our project, the frontend developers started to use the Flow type system. At that time it was the popular choice and since there were only two or so developers, there wasn't much of a discussion or analysis, it was just a starting point.

Over time, the team started running into issues with Flow (I'll save the details of that for another blog post). At the same time, TypeScript was gaining popularity and we were seeing many other teams finding success with TS, and particualrly those that were moving over from Flow.

We decided to try it out and adopt it in a small part of our codebase. So we had a 90% Javascript with Flow codebase, and 10% TypeScript. The team started to really love TypeScript. They found that more and more peers were making the switch, and there were more and more resources available. Likewise there were less and less resources and peers using Flow.

The team really wanted to continue migrating the codebase from Flow to TypeScript. But by this time, with a team of a handful, supporting a huge codebase, the cost to complete this migration was hefty, and not something the organisation was prepared to pay.

All the time whilst this was happening, the backend developers were also exploring the use of TypeScript on the backend. In particular the NestJS framework. Suddenly there seemed to be a compelling case for why migrating everything to TypeScript made a lot more sense. Could we find the magical unicorn of a single language across frontend and backend? The answer is yes, sort of, mostly, time will tell.

As time went by, the decision to move to TypeScript and utilise the same language across the whole stack was solidified. The team was happy, the codebase was happy, and the organisation was happy.

To this day, the codebase is still undergoing a transition to full TypeScript. This work has also been combined with other platform re-architecturing such as moving to a monorepo and other exciting projects that I will write about soon 💪.


About

AboutFAQsBlogContact

Browse & search

© 2024 DevBuilt

Built by TimE

🌐 Insights by EventScout