79103911

Date: 2024-10-18 23:16:58
Score: 0.5
Natty:
Report link

Just discovered the @overload tag, which seems to do what I need:

/**
 * Handles the value of "val" based on the "type" parameter.
 * @function example
 * @overload
 * @param {"number"} type - The type of the "val" parameter.
 * @param {number} val - The value to handle.
 * @returns {void}
 */
/**
 * Handles the value of "val" based on the "type" parameter.
 * @function example
 * @overload
 * @param {"string"} type - The type of the "val" parameter.
 * @param {string} val - The value to handle.
 * @returns {void}
 */
/**
 * Handles the value of "val" based on the "type" parameter.
 * @function example
 * @overload
 * @param {"boolean"} type - The type of the "val" parameter.
 * @param {boolean} val - The value to handle.
 * @returns {void}
 */
function example(type, val) {
  // handle "val" based on "type"
}

Not entirely sure why this isn't documented on the JSDoc website, but it seems to work with IntelliSense on VS Code.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: simplexshotz