Take advantage of TypeScript’s type-checking without a compilation step

JSDoc refers to JavaScript documentation through comment blocks, it is similar to the JavaDoc. With it, it is possible to type-check your JavaScript code and avoid setting up a build/compilation step in your project. This method still requires TypeScript, but only for developing, not to ship your code.

Why would anyone want to use JSDoc instead of TypeScript for type-checking?

If you’re building a frontend application using a library like React, you will probably use a tool such as Webpack (or Vite) to bundle/compile your code into JavaScript that browsers can understand. In that case you might as well use TypeScript because you already have a build step. Though, if you think the Hot Reloading or the build step are too slow, JSDoc could still be of help.

Now if you’re building a library, then JSDoc becomes really attractive. It allows you to document your library and type-check your code without requiring you to have a build step. You can focus on coding then publish your library as is.

#javascript #jsdoc

Type-check your JavaScript with JSDoc
42.45 GEEK