August 29, 2022
In this article, Sergey Otmorsky, the Lead Developer of Usetech, highlighted the main points that should tip the scales towards TypeScript when choosing a programming language.
1. TypeScript is very simple
2. Switching from JS to TS makes life easier
Gross errors made during code modification are visible immediately, not during execution. This especially helps with those parts of the code that are executed under tricky conditions. No more, ‘X’ is not a function.
When many years ago I was offered to help with some simple tasks for the frontend team, I had no idea what a nightmare it was to modify the JS code. Added a parameter to the function, but didn’t notice one of the calls?! You’ll only find out about it when you start executing the code. If you’re lucky, of course. A call, maybe, inside a tricky if expression, or even pretend that this is the way it should be. If there are several such errors in a row, then, at best, it will be possible to catch the first of them and check first. Although I love variety, I started to give up on JS tasks.
With TS, it’s quite the opposite, I even like it. The code affected by the modifications is visible immediately in the development environment, you no longer need to look carefully yourself.
You can program almost anything with TypeScript: mobile and desktop applications, back and front parts of web services.
4. Academic interest
Despite its simplicity, TypeScript allows you to do amazing things. For example, write a type generator that can find a way out of the maze at the compilation stage.
JS/TS has a huge community. There are many ready-made open solutions. In TS, you can use JS code, and you can explain to TS how JS code behaves by adding type definitions. For many popular JS-only libraries, type definitions already exist.
Its own convenient sandbox in which you can test which JS TS turns into. You can try to write and run the TS code directly from the browser, without configuring anything locally.
7. It can also be useful in everyday life
On any page in a web browser, you can run your own JS code, which means you can script some routine actions on the site or even fix broken functionality. One day I was asked if I could get the maximum discount in the store. The size of the discount depended on the result of a mini-game in which a man crawls up a rope if you click with the mouse, and slides down constantly.
8. Good type inference system
Perhaps after reading this brief review, you agree that TypeScript is convenient, simple, and interesting to learn, especially if you are just starting your way in programming.
The article is also available in our corporate blog on Medium.