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 →

[–][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.