callmepk@lemmy.world to Programmer Humor@lemmy.ml · 2 years agoMe, migrating my code from JavaScript to TypeScript:lemmy.worldimagemessage-square32linkfedilinkarrow-up1344arrow-down114
arrow-up1330arrow-down1imageMe, migrating my code from JavaScript to TypeScript:lemmy.worldcallmepk@lemmy.world to Programmer Humor@lemmy.ml · 2 years agomessage-square32linkfedilink
minus-squarealokir@lemmy.worldlinkfedilinkarrow-up5arrow-down1·2 years agoNot necessarily, depending on your situation you can type the JS code yourself. If the team making the JS code were using jsdoc then the Typescript compiler can recognize the comments and use it for type checking. In some instances the compiler can infer types from JS code to do some basic validation. Even if the external JS code is recognized as any, your own code that’s using it still has types, so it’s better than nothing.
Not necessarily, depending on your situation you can type the JS code yourself.
If the team making the JS code were using jsdoc then the Typescript compiler can recognize the comments and use it for type checking.
In some instances the compiler can infer types from JS code to do some basic validation.
Even if the external JS code is recognized as
any
, your own code that’s using it still has types, so it’s better than nothing.