top | item 40921183

(no title)

botten | 1 year ago

With types as jsdoc annotations there is no compilation step at all, no matter where the script runs. Have your cake and eat it.

discuss

order

satvikpendem|1 year ago

JSDoc is strictly less powerful than TypeScript though. For example, more complex types as well as template literal types are impossible to have in JSDoc. It is simply more ergonomic to use TypeScript instead of JSDoc.

novagameco|1 year ago

Are you saying there isn't any tool which checks whether you're using your types correctly? If not, then the two aren't comparable at all

wilsonnb3|1 year ago

There are tools that check whether you are using your types correctly. They work like linters, where you get hints in your IDE and you can run it across the whole project looking for problems when you want to.

The difference between this approach and the typescript approach is that typescript isn’t valid JavaScript, you need a build step that converts it. JavaScript with JSDoc type annotations is valid JavaScript, just with special comments in it, so it doesn’t need to be converted before it is run.