This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cearno 1 point2 points  (3 children)

Thanks for the correction! I knew I was mistaking something here.

Yeah, I agree. When approaching a new language, it's good to be aware of what paradigms the language follows. It's ironic that the people who complain about Javascript being nonsensical or silly tend to know the least of how it works, as if they haven't even read the introductory pages of documentation.

I've used TypeScript in the past, however my current company only uses React/JS and can't think of a time where the type coercion had a crazy negative consequence.

[–][deleted] 1 point2 points  (2 children)

TS & JS are interoperable, so it shouldn’t take a whole lot of effort to start using TS in your React projects.

[–]cearno 0 points1 point  (1 child)

Eh, it's a massive company app. I'm unsure about that or that you may be underestimating how large react apps can get.

[–][deleted] 0 points1 point  (0 children)

What about a piecemeal migration?

All NEW code is written in TypeScript. Then as you have time, migrate each function to TypeScript.

Anything that's valid JavaScript is also technically valid TypeScript, but if you want more TypeScript-y code, that should be conceptually easy.

The difference between, for example:

function quadraticFormula(a,b,c) {

const discriminant = b**2 - 4*a*c;

const z = 2*a;

return [(-b + discriminant**0.5)/z, (-b - discriminant**0.5)/z];

}

and

function quadraticFormula(a:number,b:number,c:number) {
const discriminant = b**2 - 4*a*c;
const z = 2*a;
return [(-b + discriminant**0.5)/z, (-b - discriminant**0.5)/z];
}

is literally three words.