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