Skip to content Skip to sidebar Skip to footer

Document Overloaded Function In Jsdoc

I have an overloaded toggle function and want to document the behaviors w/ JSDoc. If the value is defined the window state is set to the boolean value of the truthy parameter, if u

Solution 1:

Taken from here:

You need to nestle the start and end of each comment together like so:

/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {(Moment|Date)} start Start of interval
 * @param {(Moment|Date)} end End of interval
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!Array} range Array containing start and end dates.
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!String} range String formatted as an IS0 8601 time interval
 */functionDateRange(start, end) {
  // ...
}

Note, however, that constructor overloads are not grouped together. Each overload still receives the full member list, such that part of the documentation becomes redundant. Might be fixable in the template, however.

Solution 2:

Since the previous answer didn't work for me. Try:

/** @type {((param: string) => boolean) & ((param: string, overloadedParam: string) => string))} */
const func = (param, overloadedParam) => { … }

Please give credit for this answer to ExE-Boss on GitHub, found here: https://github.com/microsoft/TypeScript/issues/25590#issuecomment-480022039

(this works in standard JS, as well as TS)

Post a Comment for "Document Overloaded Function In Jsdoc"