A
A
aki22020-10-21 20:38:49
Node.js
aki2, 2020-10-21 20:38:49

Do I need TypeScript to write a Node.js backend?

Is it possible to get by with regular js?
What will be the benefits?
Wouldn't there be a lot of extra writing compared to pure js?
Will it be difficult to store compiled js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-10-21
@aki2

Is it possible to get by with regular js?
Can. TypeScript only adds static typing to JavaScript in compile time. After compilation there will be all the same JS.
What will be the benefits?
The main plus, IMHO, is the speed of development due to IDE hints and auto-completion, more auto-refactorings. Well, the ability to restrict the use of functions / methods from unwanted use is also a plus. And if you also design a domain model on types, then you can immediately see if something does not converge, even before writing logic.
Wouldn't there be a lot of extra writing compared to pure js?
Most TypeScript types are able to infer. Far from Hindley-Milner, of course, but also good. I write more in the FP style, with a rare admixture of structural-procedural when describing effects, so I have explicit type indications only in function signatures. In the logic itself, the code is indistinguishable from regular JS, but with good type checking.
Will it be difficult to store compiled js?
Like any other build artifacts, compiled JS does not need to be stored. Compile just before putting it into production, and in git store only TS code + compiler settings. And in the dev environment, you can generally run through the ts-node module.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question