Microsoft/TypeScript
Auf GitHub ansehenJsDoc with overloads and different generics results in wrong dts output
Open
#59.980 geöffnet am 16. Sept. 2024
BugDomain: JSDocHelp Wanted
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
🔎 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