Intive-FDV Blog

Typescript: Love at First Line of Code 

We had a huge project in our hands. The team was growing day by day and the code in Javascript looked unmanageable: there were folders and more folders of untyped code. We didn’t know how to scale up, nor how to integrate all the developers that continued to join the team. Just then, we discovered Typescript, a syntactical superset of Javascript.

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.

I Started Using Typescript behind Javascript’s Back 

Typescript is a superset of Javascript, which means that it’s part of Javascript but has “super powers”. What can it do?

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.

We take this in Javascript…

… and replace it for this in Typescript:

2) Implementation of the latest features of Ecmascript

Typescript transpiles the code to Javascript and makes it compatible with any browser, while also implementing features like Spreed Operators, Promises, and Async Await —available with the latest versions of Ecmascript— with no need to make additional configurations.

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.

In conclusion:

Any software development enthusiast has free access to the Typescript code in GitHub and can leave their contribution there. The fact that Microsoft created it means that it’s highly supported by the software community. In addition, TypeScript can be used to develop JavaScript applications for the client or in the server.

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?

Ilein González

Ilein González has a degree in Social Communication, journalism mention, graduated from the Andrés Bello Catholic University. Since May 2018 she has been working as a Quality Analyst at intive-FDV, in one of the most challenging projects of the company. Ilein is also an enthusiast of innovation and processes.

Add comment