简体   繁体   中英

How to document array elements in jsdoc?

I have a function that returns an array of two element. For given comments, VS code Intellisense is working fine, but when I generate docs using jsdoc, It throws the error.

ERROR: Unable to parse a tag's type expression for source file... with tag title "returns" and text "{[state: initialState, dispatch: Function]}.

/** 
 * @typedef {object} initialState
 * @property {string} locator_id - ID 
 * @property {boolean} loading - 
*/

/**
 * @namespace Context
 * 
 * @returns {[state: initialState, dispatch: Function]} 
 */

You can use:

 /** @typedef AR_INNERJOIN @type {Set} @property {string} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at feugiat enim, eu mattis turpis. Duis suscipit, libero eu sagittis faucibus, velit urna pulvinar ex, sit amet sollicitudin leo dui in arcu. */ /** * sample inner join set * @type {AR_INNERJOIN} */ this.internalConnections = new Set();

The JSDoc syntax for an array of object is:

/**
 * Description here...
 * @returns {Array.<{state: initialState, dispatch: Function}>}
 */

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM