Typescript helped us make the code understandable by either one of us or a third party. In addition, this superset enables integration with Visual Studio Code, the code editor we were using. That was one more reason to choose Typescript.
Typescript’s main advantage is that it employs types, so we can establish the types of data to be included in the variables and the types of data to be returned by the functions. This characteristic makes the code easier to understand and implement. Besides, being able to control types gives us the chance to identify errors in the early stages of code writing and transpilation. And there are a few other advantages:
1) Integration with tools such as Visual Studio Code
Visual Studio Code integrated with Typescript provides an early feedback of the variables’ definitions, thanks to which we can capture a variable that’s likely to be undefined and also validate its behavior when it actually is, so that it works the way it’s supposed to. This results in a better development experience.
… and replace it for this in Typescript:
2) Implementation of the latest features of Ecmascript
3) Default documentation
Using static types is one of the best ways to document the code because it provides a signature for our functions, but there are other tools to generate documentation, such as JSDocs.
4) Readability and scalability
Statically typing increases the code’s readability, helps to understand the legacy code and improves refactoring and bugfixing times, which results in a substantial improvement of the code scalability.
One disadvantage of TypeScript is that it’s wordy: you have to write more to execute the same things. However, its syntactic similarity to Java or C makes it more flexible for programmers who are already familiar with these languages.
Has any of you used Typescript? Can you tell us a bit about that?