In recent weeks I have seen several posts asking questions such as:
Should we be using TypeScript on our project?
For me the answers are obvious but might not meet with wide approval.
To answer the first question "learn JS or TS" the answer has to be JS then TS. Nowadays to become a professional web application developer you need both. You first need a firm foundation in JS before adopting TS. After all, the web browser and Node do not understand TS (unlike Deno). When debugging code, you might have access to source maps that link the obfuscated JS code to the TS instructions but sometimes to need to delve deep into the JS and get as close to the JS processor as possible to discover the root cause of issues.
I am of the opinion that when developing a project in a team TS makes considerable sense especially when the team is indoctrinated in OOP. One of the worst arguments I came across of adopting TS was "Most of the team are actually C# developers and they do not want to learn JS". My answer would be "keep them backend but not on Node". The justification was that TS, with its strong data typing, is closer to C#, but this is a fallacy. TS provides some additional checking to help the developer identify potentially in appropriate use of variables (given a hint of their expected type) but this is a development-time, not a run-time feature.
I have had to battle this assumption several times and even Microsoft have changed their take on the role of TS in relation to JS.
One issue I have found it TS pushes the development more along the OOP route than I like. As I extend my coding style to employ more FP (Functional Programming) techniques, I have found that TS can make the function declaration considerably more complicated but perhaps I am doing it wrong.
Top comments (1)
True the browser does not understand TS. However, Node is another story, as you said there's Deno, but there is also ts-node-dev (or ts-node), which understand TS.
It's understandable that C# developers would prefer TS over JS because they're used to a type safe language. The joke is on them though, because if they learn TS, they also know JS 😂