How (and why) you should use TypeScript with Node and Express.

Arlion_Code·2020년 9월 16일
1


During the beginning of my career, I was a desktop developer, where strong typed languages dominate the market.
When I migrated to web development, I was fascinated by every new feature on languages like JavaScript and Python. The fact that I didn’t have to declare the type of variables brought me productivity and my work became more fun.
So the first time I heard about TypeScript, the idea seemed like a step backwards in the evolution of the language.
Did I change my mind?
Yes, but it depends on the case. For personal projects, in which I work alone, I still prefer the productivity of plain JavaScript. But, for larger projects, where you work as a team, I recommend using TypeScript. Throughout this article I will explain how and why.
TypeScript
If you still do not know what TypeScript is, I recommend reading this overview: https://www.tutorialspoint.com/typescript/typescript_overview.htm
And the official 5-minute tutorial:
https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
But we can say, superficially, that it is ECMAScript 6 with strong typing.
Productivity vs maintenance
By definition, “TypeScript is JavaScript for application-scale development”. That is, the work we have with the initial setup of the project is compensated with the maintainability of complex projects. Let’s point out why this happens:
Type safe = less errors
By defining types in your code, you allow the IDE to acknowledge errors in the use of classes and functions that would only be perceived at runtime.
Example:
Here I am using Visual Studio Code which points put two errors:
On line 6: we are trying to pass a string parameter to a function that only accepts numbers.
On line 9: we are trying to assign, to a string, the result of a function that returns a number.
These two errors would go unnoticed, without Typescript, resulting in some bug on the final application.
The IDE exposes the project modules more easily
In complex projects we have hundreds of classes distributed across multiple files. When we define types, the IDE is able to relate objects and functions to the files that gave origin to them.
When using control + click on a method or class, imported from another file, the IDE will automatically navigate to the imported file, highlighting the line where the reference was defined.

We can use autocomplete in classes that have been imported from other files.
The difficulty of maintenance is one of the main reasons why Java and C # developers avoid migrating large projects to JS. We can say that Typescript is an enterprise language that overcomes this barrier.

profile
____adsa

5개의 댓글

comment-user-thumbnail
2020년 9월 16일

How (and why) you should use TypeScript with Node and Express.

답글 달기
comment-user-thumbnail
2023년 6월 18일

First and foremost, one of the most crucial aspects of treadmill maintenance is keeping it clean. Over time, dust, dirt, and sweat can accumulate on the surface, making it less efficient and potentially causing damage. Regularly wipe down the console, handrails, and belt with a damp cloth to remove any grime. visit, click for more info, Use this website, click to read more, find more info

답글 달기
comment-user-thumbnail
2024년 1월 9일

Our Panaji Escort Service ladies are adorable, fashionable, and charming enough to make you fall in love with them at first sight. If you're single and looking for a female escorts service in Panaji, our escorts will be your actual companion at that time.

답글 달기
comment-user-thumbnail
2024년 1월 15일

Spending time with our Call Girl in Bicholim will allow you to witness the deep passion that they have to give. They will go to any length to satisfy you. Their main goal is to make you happy, so you can return home with a pleasant and pleasing heart.

답글 달기
comment-user-thumbnail
2024년 3월 1일

The Imperial Hotel Delhi Escort offers various services. In-call Call Girls require booking an appointment through a dating website, then the girl will call to meet you. College Call Girls The Imperial Hotel Delhi are also accessible through our services, creating an account and receiving contact details of your chosen woman requires minimal effort on your part on our website.

답글 달기