brettz9 / jsdoc-jsonschema

Convert standard JSDoc @typedef comment blocks into JSON Schema (with support for nonstandard expansions).
MIT License
6 stars 0 forks source link

Error when parsing `@property {string[]} list` #1

Open alastormininister opened 1 year ago

alastormininister commented 1 year ago

First of all, great lib and great work. I'm finding the below error when parsing the below declaration, maybe someone can tell me how to declare arrays?

TypeError: Unsupported jsdoc type GENERIC
/**
 * @typedef {object} Context
 * @property {string[]} list
 */
brettz9 commented 1 year ago

Glad to hear it's getting used.

I've just pushed v0.12.0 which should support that scenario you describe.

I really should overhaul the logic to use jsdoc-type-pratt-parser, but am really too preoccupied at the moment to do so. For now I can hopefully add any missing support for some simple cases as you describe.

But note that if you had something like:

/**
 * @typedef {object} Context
 * @property {string[]|number[]} list
 */

...this will not put the types into an anyOf or such. I'm afraid I just don't have too much time to dedicate to this at the moment. But if a simple case comes up like this, I can see if it is something I can add support for quickly.

Let me know if the new version works for you.

brettz9 commented 1 year ago

I've also added support for:

/**
 * @typedef {object} Context
 * @property {string[]|number[]} list
 */
alastormininister commented 1 year ago

Awesome, man! And thanks for the quick turnaround. It looks great at first glance. I’ll let you know if I run into issues. And hey, if I can convince my company to go with the approach I’m experimenting with maybe we’ll have some time to contribute as well 🤞