Hasty Briefsbeta

JSDoc types are not TypeScript types

5 days ago
  • #JavaScript
  • #JSDoc
  • #TypeScript
  • JSDoc types are not recognized by npm, jsdocs.io, or tsdocs.dev.
  • npm displays the 'TS' badge only if 'types' key is specified in package.json pointing to a .d.ts file.
  • tsdocs.dev and jsdocs.io require .d.ts files to work properly.
  • VSCode's TypeScript Language Server recognizes JSDoc types but doesn't process node_modules/**/*.js the same way as .d.ts files.
  • Using JSDoc-typed npm packages results in TypeScript warnings about missing declaration files.
  • To resolve visibility issues, use 'tsc --allowJs --checkJs --declaration' to generate .d.ts files from JSDoc types.
  • An alternative approach is manually writing .js files without types and separately providing types in .d.ts files.
  • The article expresses frustration that 'just use JSDoc' isn't fully viable yet for eliminating the JS compile step.