You are currently viewing Why we use Typescript in ReactJS? | Beginners Guide

Why we use Typescript in ReactJS? | Beginners Guide

React with typescript

Why typescript?

We are happy to write react applications with just JavaScript. So, do we need to learn to react with typescript? We were also at that stage, but having used typescript for a while, we can safely say that it has improved the overall development experience.

  • With static type checking, you get to learn about potential bugs as you are typing the code, then heading to the browser and figuring it out at runtime.
  • It also provides a way to describe the shape of an object, hence providing better documentation and autocomplete.
  • Typescript even makes maintenance and refactoring of large code bases much easier.

As you can see there are some pretty good points to help you make the decision of adopting typescript in your code.

Now you might be thinking, I have also heard people say that typescript is just frustrating most of the time. I have to write a lot more code than I usually do and the compiler keeps complaining. I don’t know what to do about those errors. It doesn’t seem to be productive for me. Again I had the same mindset but I have to look at typescript as an initial investment that pays off in the long run. Once you get the hang of it, you will realize that the benefit you get outweighs the additional time spend on it.

Leave a Reply