Microsoft/TypeScript
在 GitHub 查看JsDoc with overloads and different generics results in wrong dts output
Open
#59,980 建立於 2024年9月16日
BugDomain: JSDocHelp Wanted
倉庫指標
- Star
- (48,455 star)
- PR 合併指標
- (平均合併 6天 17小時) (30 天內合併 9 個 PR)
描述
🔎 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