Closed
Description
π Search Terms
overload jsdoc
π Version & Regression Information
Because @overload
was introduced in TS 5.0, I don't think this is a regression. It may just be something that was missed when overloads were introduced.
β― Playground Link
π» Code
/* -------------------- Distinct Docs -------------------- */
/**
* Do something with number
* @overload
* @param {number} a
* @returns {void}
*/
/**
* Stringing
* @overload
* @param {string} a
* @returns {void}
*/
/**
* @param {string | number} a
* @returns {void}
*/
function doSomething(a) {}
doSomething(1);
doSomething("");
Also See
/* -------------------- Fallthrough -------------------- */
/**
* This does something different
* @overload
* @param {boolean} b
* @returns {void}
*/
/**
* @overload
* @param {object} b
* @returns {void}
*/
/**
* @param {boolean | object} b
* @returns {void}
*/
function doSomethingDifferent(b) {}
doSomethingDifferent(true);
doSomethingDifferent({});
/* -------------------- Deferred Fallthrough -------------------- */
/**
* @overload
* @param {Event} c
* @returns {void}
*/
/**
* Only Mutation Observers do cool things
* @overload
* @param {MutationObserver} c
* @returns {void}
*/
/**
* @param {MutationObserver | Event} c
* @returns {void}
*/
function anotherThing(c) {}
anotherThing(new Event("click"));
anotherThing(new MutationObserver(() => {}));
π Actual behavior
The types resulting from the JSDocs are correct, but the comments are lost. This same issue occurs for overloaded constructors.
π Expected behavior
As is the case for regular overloads in TypeScript (example), I would expect my JSDoc comments that use the @overload
tag to be preserved.