Typescript dilemma, when to use it?

Typescript dilemma, when to use it?

04 August, 2020

Typescript is a strict syntactical superset of JavaScript and adds optional static typing to the language. It compiles to plain JavaScript. I have been using Typescript for several years in multiple projects. While the promises from the technical perspective are exciting, it is not for every project. In this post, I will be talking about my opinions and decision-making process to use it or not.

For lean startups, one of the advantages of Javascript is its freedom. Making a feature work for validation is not a problem at all. Especially for early startups with a low budget, Javascript cuts the engineering costs significantly. However, in most cases, the product ends up like spaghetti, unable to scale and iterate. Typescript keeps things a bit more under control for the future.

Typescript designed for enterprise. It was hard to control the code quality for large scale teams as Javascript is too flexible to scale. While traditional object-oriented programming languages require more strict typing and fewer potential bugs, this increases development time significantly. Typescript is trying to address scaling these issues by introducing the intermediary compiling step. While it is a great idea, execution is not that smooth still.

Advantages of Typescript

While the syntax improvements that Typescript offers is not much significant with new ECMA script improvements, Typescript still shines on:

  • Typescript code is more readable and structured as it forces the developer to think about the data structure before writing the code.
  • Static typing allows you to catch errors earlier in the debugging process.
  • It serves as an extra protection layer over the Javascript code. Potentially decreases the number of tests to write.

Disadvantages of Typescript

The disadvantages come from the nature of Javascript language. It is not easy to design a programming language that turns chaos into order. So Typescript developers suffer the consequences.

  • Typescript is optional. Every rule can be disabled. Furthermore, Typescript can work side by side with Javascript. These options can introduce more complexity than a pure Javascript code.
  • Typescript itself is not bug-free. Developers sometimes need to deal with errors thrown by the compiler while it is a legit Javascript snippet.
  • Not all Javascript libraries come with Typescript typings. Consuming those libraries can be cumbersome. It can cause motivation and productivity issues.

Personally, Typescript takes away the flexibility and the phase of Javascript language. When the target of the code is for a wider audience, Typescript is a perfect fit. On the other side, if you are experimenting with your idea, it will be just a burden.

When to use Typescript?

After some points background information about the advantages of disadvantages of Typescript, let’s talk about when to use it. These are my opinions coming from the years of experience I had with Typescript in production apps.

For a Javascript library, Typescript language is almost a must now. The popularity of Typescript is increasing every day. The developers consuming your library would expect it to work with it smoothly. While there is always an option to add the typings as a separate library, it will create more jobs for you, as for each API change, you need to update your typings. Furthermore, Typescript will make the library code and API more understandable. As most of the IDE’s have first-class support for Typescript, you will be offering a more smooth development experience to your library consumers.

For an MVP (minimum viable product), better to stick with Javascript. In the experimentation stage, your biggest weapon is to iterate fast. Especially when your team is not mature yet, you will be losing precious time. Typescript in less experienced teams creates more problems as it requires more fundamental knowledge of computer science and programming. When it is time to scale your product, you can always find the time and resources to migrate.

For a large scale, enterprise solution, Typescript is perfect. When the engineering team is large, management becomes much more complicated. Typescript allows architects to pass their vision down to the team more clearly. It keeps the code under control, making the code review process simpler. As senior members of the development team control the rules of the codebase and the architecture, junior members can concentrate on details.

Final Words

Javascript is a free beast. Even using Typescript with a code linter is not enough to restrict it into a scalable language. Although Typescript is a solution for code that will be consumed by larger development teams or community, it is not for small projects or the first days of a fresh startup. It is always possible and not that complicated to migrate to Typescript when you feel the need.


Solution ArchitecturePlot out your idea to a realistic path toward higher enterprise in a lean way
Product ManagementCombine the technical expertise with lean product approach, find the market fit, scale
Engineering ManagementWise resource coordination, clear goals, on-time delivery with maximum quality
target Contact Me

Ready to get started?

Complete this form and I will get back to you as soon as possible.

contact me