jsdoc-plugin-typescript
jsdoc-plugin-typescript copied to clipboard
Incorrectly casts `export type X` declarations to class
If I use any combination of
// types.ts
/**
* Valid JSON primitive types.
*
* @arbitrary_tag IncludesNotAddingTag
*/
export type JsonPrimitive = (
| string
| number
| boolean
| null
| JsonPrimitive[]
| { [key: string]: JsonPrimitive }
);
with
// index.js
// includes any combination of @typedef {typeof import...}, lack of typeof, etc.
/** @typedef {import('./types').JsonPrimitive} JsonPrimitive */
The plugin fails with:
Error: Invalid docstring * @typedef {Class<import('./types').JsonPrimitive>} JsonPrimitive in /path/to/index.js
TL;DR
Don't automatically cast type declarations to class (who else does that?).
Edit: I realize this plugin was made primarily for classes, but for > 1k downloads, I'd expect it to be a bit more supportive of other types as well.