Microsoft/TypeScript
View on GitHubJsDoc with overloads and different generics results in wrong dts output
Open
#59,980 opened on Sep 16, 2024
BugDomain: JSDocHelp Wanted
Repository metrics
- Stars
- (48,455 stars)
- PR merge metrics
- (Avg merge 6d 17h) (9 merged PRs in 30d)
Description
🔎 Search Terms
javascript jsdoc dts overload
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about jsdoc
⏯ Playground Link
💻 Code
/**
* @template {string} Element
* @overload
* @param {Element} element
* @returns {() => void}
*/
/**
* @template {boolean} Element
* @overload
* @param {Element} element
* @returns {() => void}
*/
/**
* @overload
* @param {number} element
* @returns {() => void}
*/
/**
* @param {any} element
*/
export function on(element) {
return () => {}
}
🙁 Actual behavior
The resulting dts of the given JSDoc looks like this:
export function on<Element extends string>(element: Element): () => void;
export function on<Element extends string>(element: Element): () => void;
export function on(element: number): () => void;
As you can see the generic does extends string both times, but it should be extends boolean the second time
🙂 Expected behavior
export function on<Element extends string>(element: Element): () => void;
export function on<Element extends boolean>(element: Element): () => void;
export function on(element: number): () => void;
Additional information about the issue
No response