How to provide shared JSDoc documentation for all function signature overloads in TypeScript?

4 weeks ago 21
ARTICLE AD BOX

I have this code

/** * One */ function debounce(callback: AnyFunction, immediate?: boolean): void /** * Two */ function debounce(callback: AnyFunction, options: Options, immediate?: boolean): void /** * Three */ function debounce(callback: AnyFunction, optionsOrImmediate?: Options | boolean, immediate?: boolean): void { // secret } type AnyFunction = (...args: any[]) => any type Options = {}

When I first start typing the function name, I only see "One" in intellisense.

enter image description here

After that, when filling function parameters, I can switch between both overloads and I either see "One" or "Two". I don't see "Three" at all.

enter image description here

enter image description here

Is there a way to provide

shared common JSDoc, such as author, description

and on top of that specific documentation for each overload?

Read Entire Article