DEV Community

Discussion on: Why I'm Learning Typescript

 
rkallan profile image
RRKallan • Edited

@Rense Bakker
try to run your TS file in a browser without compiling to JS. Also there are no plans to support that in a browser.
Typescript extends JS by adding types.
And yes there are benefits using TS.
The downside is that some developers are not aware that your code still can fail on production. I see by getting data from (external) api which is unexpected type, missing. The code breaks on production. Because there are trusting on mockData and TS.
Yes the problem comes from the api. But still your code needs to catch it instead breaking.

There is a proposal to adopt type notation in JS

Without JS no TS

Thread Thread
 
rkallan profile image
RRKallan

@Rense Bakker
one more thing what we can see a lot in code, when using TS. Is typing to any to avoid TS error.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Just adding that there are multiple proposals for adding optional type notation into JS core API (including TS itself, Flow and others) but AFAIK none of them reached a stage to be considered a possibility in the short term.

Another issue I faced one time (but I bet is not the only place where this happen) is being on a project where they had budget either for using TS or for applying TDD... They choose TS which is an aberration if you advocate for quality. Also two things happen: an imminent lack of confidence in the code in the short term and tech debt growing quickly. (This is not usually perceived by core team till the exact point where some devs start leaving and new ones come in).

Thinking that TS will magically convert your code into good, robust and trustable code is just ridiculous.

It has benefits and I expect a growth in the amount of business asking for TS in their open job positions because TS + TDD is usually better than JS + TDD.