When to use and not to use typescript


When to use and not to use typescript in a react application?

First let's explain what is typescript

Typescript is a superset of Javascript that allows us to use types, there are many benefits to typescript like preventing errors with defining the types, error caching while in real time instead of when running the application and much more.

So why to consider not using typescript?

First of all it takes some time to get used to it, usually when starting using typescript (at least from my experience), the development speed decreases and some really simple code can take a long time to figure out how to type it. Beside that lets say that we are working on a full stack app with a backend server like Nodejs, usually my preference is to use typescript only on client side and I will explain later why.

When you should use it

  • If you work on a medium or bigger project which includes your custom backend it will help a lot to keep the projects clean and avoid unnecessary bugs.

  • If your working on a team, I still didn't had the opportunity to work on a team but from my understating it will be much easier to use typescript when working with people, because everybody can see the types and props and all the values right away instead of guessing or checking what the other developers meant to do.

  • If you come from a typed programming background, this one is pretty self explained if you used to types just continue with them.

When to consider not to use it

  • The opposite here will be a small project, let's give some examples, personal blog, landing page, portfolio and so on.

  • When using the CMS, I found it pretty hard to make mistakes while using CMS (so far), I think it may not be worth the time when you only make queries in your application. When using CMS all the data creating and updating is created separately and the client only makes queries to fetch the data so it may be a little overkill to use Typescript in this case.

  • If you are creating a full stack app with a backend I don't see the point using Typescript on your server, because the backend is usually pretty organized and it can be overkill to push typescript there. The front on the other hand usually will contain more code and will be more messy by its nature, so yes you should consider working with typescript on full stack apps.

P.S just remember that it is still only my opinion based on my experience and everybody is different and free to do whatever they find most comfortable.

Could not load the image

© 2021, Built by Michael Donchenko