Microsoft/TypeScript
Vedi su GitHubJsDoc with overloads and different generics results in wrong dts output
Open
#59.980 aperta il 16 set 2024
BugDomain: JSDocHelp Wanted
Metriche repository
- Star
- (48.455 star)
- Metriche merge PR
- (Merge medio 6g 17h) (9 PR mergiate in 30 g)
Descrizione
🔎 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