javascriptjsdocjsdoc3

JSDoc: reference @param of method in another @param


I am new to using JSDocs and couldn't find an answer to this question.

Suppose I wanted to write this simple function:

function hasQ(array, item) {return array.includes(item);}

which with JSDoc's I would mark-up like:

/**
* Another way to call array.includes(item);
* @param {Array} array
* @param {*} item to test if contained in array
* @returns
*/

Is there a way for me to markup the word array in the second @param statement such that it references the first @param?

This is just a toy example, but I hope it makes the concept clear.


Solution

  • I did not see the possibility of writing related parameters (but see parameters with properties). But you can write description ;)

    /**
     * @method
     * @param {Array} array - description for this param
     * @param {*} item - description for this param
     * @description Please write your description for Method
     * @returns {*|boolean}
     */
    const hasQ = (array, item) => array.includes(item);