What ends up being written is not TypeScript syntax (which does require transpilation to run).
JSDoc is awesome for incremental adoption though, I've migrated a few codebases this way without too much pain.
What ends up being written is not TypeScript syntax (which does require transpilation to run).
JSDoc is awesome for incremental adoption though, I've migrated a few codebases this way without too much pain.
Incidentally I've been doing my JS projects this way for 2-3 years and I really dig it.
Actually since this conversation is going, here's something I just learned this week that somebody might find helpful. I used to consider enums one of the clunky bits, but I just ran across the `keyof` operator:
var modeNames = { FOO: 1, BAR: 2 }
/** @param {keyof modeNames} mode */
export function doThing(mode) {
// the jsdoc type above is equivalent to {'FOO'|'BAR'}
}
Probably old hat to TS people, but since I came at it from the other direction (I'd been using JSDoc for traditional doc-creation reasons before I realized VSCode could use it for linting and type hints) it was news to me.- Type checking
- Transpiling to multiple formats (CJS/ESM, JSX and the like)
- Generating declaration files (.d.ts)
While there are modern alternatives for transpiling, much faster than tsc (esbuild, swc), typechecking and declaration generation are still very slow operations.
You just need to call this from somewhere like ts-morph.