Why You Should Use Typescript

christopher-gower-m_HRfLhgABo-unsplash (2)
Photo by Christopher Gower on Unsplash

Everyone who uses the JavaScript ecosystem is currently apprehensive of typescript. However, typescript is one of the most cherished technologies *, and its operation is constantly adding (operation share increased from 52 in 2018 to 78 in 2020) *.

The current position of Typescript came out of nowhere as that technology is suitable to alleviate our inventor experience. Further unequivocal coding increases the control and pungency of law. In this composition, I will try to move you to use Typescript.

*-Data source State of JS 2020 and Stack Overflow Inventor Survey 2020.

Find out about earlier errors.

Generally, when you’re developing an operation in JavaScript, your inflow might look like this

1. Make a change,

2. Go to the app, check out the changed part/ Run (related) tests.

3. Find out if everything is ok.

With Typescript, you can make the change, and if there is an error in your law, you’ll know thanks to the compiler error communication or IDE real-time feedback incontinently. Of course, the Typescript compiler will not resolve every problem and will not advise about all your bugs, but its help could be invaluable.

More syntax completion in IDEs

It’s really simple. However, like WebStorm or VSCode, you’ll get better syntax completion with typescript if you’re using good IDEs. Perhaps it does not sound like a huge inventor experience enhancement but ultimately, every single enhancement matters as it could save us some time and, again, help from a mistake. So also, we can define our type or interface formerly; as we do not always have to remember structure, we can concentrate on writing business sense.

Lower painful refactoring

Let’s say you have to refactor for whatever reason; for illustration, you joined a design and got the task to add a new point, but that point is ever connected with inheritance law. Typescript can make it easier and lower pain because when you make a change, and there is another place where you have to make another change, the compiler will advise you about that.

For illustration, it could be a changed function hand, or perhaps after the change, a function will return something completely different, so the returned type will also differ.

Be more confident about the codebase.

JavaScript is weakly and dynamically typed, so when you initialize a variable with the value let query =” latterly in law, the inventor may do commodity illogical by mistake, for illustration query = true, and it’ll be valid JS law.

In a well-written law, assigning a Boolean value to a primary string variable shouldn’t be. So, generally, that assignment with type change results from a mistake.

When using Typescript, we cannot change the type of the variable, so if we make the let query =” variable, it’ll be string type, and we will not be suitable to change its type by mistake.

Still, we always do it explicitly using union type, for illustration string| number, if we want to let a variable be further than one type.

Thus, Typescript makes our law more predictable and unequivocal. Also, Typescript will take care of explicitness in control inflow analysis, and if there is a possibility that the commodity could go awry, it’ll advise you.

Easy, progressive migration from JavaScript

Valid JavaScript law is also valid Typescript law so that you can resettle your codebase step by step. Generally, using strict mode in Typescript is good practice, but in this case, we’ve to start with” strict” false intsconfig.json, and we should also set 2 further options.

“Allows” true, //it’ll allow us to use js. Lines.

“skipLibCheck” true//it’ll skip checking types in libraries that we use

We can move from JS to TS step by step with those options – train by train, simply changing the extension. js (x) to. ts (x) and adding types in the lines. Using this approach, we can avoid hundreds or thousands of scary compendium crimes.


We should use Typescript as frequently as possible because it’s salutary in the long term. It helps to maintain systems, increases inventor experience, and makes the codebase more unequivocal and dependable.

Still, there are always exceptions – for illustration, for a simple page where JavaScript is only used for toggling class or another simple case, Typescript makes no sense. Also, we’ve to remember that to take full advantage of Typescript, we’ve to learn to use it in a good position, and it can take some time. So we suppose it’s still a veritable