So, here’s our case for why we love Typescript, and why you should try it out, too.
- it works both client-side and server-side
- It’s everywhere, which makes it easy to recycle and reuse code
What makes a static type system such a significant addition? Because it allows any developer to quickly catch more bugs, and avoid relatively easy mistakes — something no one is immune to. You thus can write safer code, faster.
For a real life example: Airbnb conducted a post mortem analysis after switching their code to Typescript. 38% of their bugs were preventable with Typescript!
Static types allow developers to clearly and explicitly define the objects and functions they are working with. It allows them to make the language more explicit, and this in turn allows the compiler to quickly spot where things are going wrong. And the Typescript compiler is incredibly powerful for catching easy mistakes.
With the addition of certain tooling, even more bugs and issues can be caught. For example, a library like Zod allows you to define a schema and validate that the code you write is valid with that schema. You give it an object, and Zod will return the same object where the type is the schema. Now you can guarantee that types are consistent with the schema.
Other projects like the TypeScript ESLint library bring a powerful linting tool, ESLint, to the world of Typescript to create assertions called lint rules around what your code should look or behave like.
Typescript can be layered in gradually
That’s good for small projects, and essential for larger projects. For the latter, it is impossible to suggest to your CTO or client to “rewrite the whole thing in a new language” — that doesn’t work. What Typescript allows you to do instead, is gradually add types, and over time improve the type awareness of your code base. Better yet: you’ll immediately unlock the abilities of the Typescript compiler to catch small bugs that you wouldn’t have spotted otherwise. As your type awareness grows, so does the soundness of your types.
You don’t even have to write all those types yourself
A strongly typed language sounds great, but who is going to write all those brittle type definitions? Who wants all that extra work of explicitly defining every last detail?
In general, by collaborating more closely with your IDE, it becomes much easier to understand what you’re working with. You can work with a certain function, and better understand what to do, what it does, and what can happen with it.
As the project grows and strengthens its types, the benefits of Typescript accumulate and reinforce. After a while, it simply results in more readable code that is easier to manage and easier to maintain. This is especially useful when more new developers come on to the project.
Are you a front-end developer that would like to work with Typescript? Consider hopping over to our hiring page, and see what positions we have open — we’re nearly always hiring for senior technical talent, so you might fit right in!