jsdoc-plugin-typescript icon indicating copy to clipboard operation
jsdoc-plugin-typescript copied to clipboard

Incorrectly casts `export type X` declarations to class

Open D-Pow opened this issue 4 years ago • 0 comments

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.

D-Pow avatar May 13 '21 02:05 D-Pow