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.
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.
satvikpendem|1 year ago
novagameco|1 year ago
wilsonnb3|1 year ago
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.