kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Support parsing of JSDoc params with sub-arrays #150

Closed kungfooman closed 1 month ago

kungfooman commented 1 month ago

Example from PlayCanvas engine:

class MiniStats {
    /**
     * Create a new MiniStats instance.
     *
     * @param {import('../../framework/app-base.js').AppBase} app - The application.
     * @param {object} [options] - Options for the MiniStats instance.
     * @param {object[]} [options.sizes] - Sizes of area to render individual graphs in and spacing
     * between individual graphs.
     * @param {number} [options.sizes[].width] - Width of the graph area.
     * @param {number} [options.sizes[].height] - Height of the graph area.
     * @param {number} [options.sizes[].spacing] - Spacing between graphs.
     * @param {boolean} [options.sizes[].graphs] - Whether to show graphs.
     * @param {number} [options.startSizeIndex] - Index into sizes array for initial setting.
     * @param {number} [options.textRefreshRate] - Refresh rate of text stats in ms.
     * @param {object} [options.cpu] - CPU graph options.
     * @param {boolean} [options.cpu.enabled] - Whether to show the CPU graph.
     * @param {number} [options.cpu.watermark] - Watermark - shown as a line on the graph, useful for
     * displaying a budget.
     * @param {object} [options.gpu] - GPU graph options.
     * @param {boolean} [options.gpu.enabled] - Whether to show the GPU graph.
     * @param {number} [options.gpu.watermark] - Watermark - shown as a line on the graph, useful for
     * displaying a budget.
     * @param {object[]} [options.stats] - Array of options to render additional graphs based on
     * stats collected into {@link AppBase#stats}.
     * @param {string} [options.stats[].name] - Display name.
     * @param {string[]} options.stats[].stats - Path to data inside {@link AppBase#stats}.
     * @param {number} [options.stats[].decimalPlaces] - Number of decimal places (defaults to none).
     * @param {string} [options.stats[].unitsName] - Units (defaults to "").
     * @param {number} [options.stats[].watermark] - Watermark - shown as a line on the graph, useful
     * for displaying a budget.
     * @example
     * // create a new MiniStats instance using default options
     * const miniStats = new pc.MiniStats(app);
     */
    constructor(app, options) {
    }
}

REPL

Currently fails here:

https://github.com/kungfooman/RuntimeTypeInspector.js/blob/037c8a5edd1ff45e216a32ff2714896dfe41b59b/src-transpiler/parseJSDoc.js#L35-L43