Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsDoc with overloads and different generics results in wrong dts output #59980

Open
dummdidumm opened this issue Sep 16, 2024 · 0 comments Β· May be fixed by #59983
Open

JsDoc with overloads and different generics results in wrong dts output #59980

dummdidumm opened this issue Sep 16, 2024 · 0 comments Β· May be fixed by #59983
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@dummdidumm
Copy link

πŸ”Ž 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

https://www.typescriptlang.org/play/?ts=5.6.2&filetype=js#code/PQKhFgCgAIWgBALgUwLYAcA2BDF0DeAzogE4CWAdgOYC+0AopmshYlLAgPYBuyJmnbABN2ceOmwlsqAo2as6yJqhZsYYkskQBXEhUIEAFAEpoAXgB80bpzJCao4FCigI6hCgw48+AEadOJmwKOjkVVlEuXn5BEXdxSWlZZVVFFIj4zR09A3wTcysbOwd1J0gXMEj4Hj4BYSqJKRl8Cm1UXz40+TUOeCzdfSNTS2tbe0dnSFcGxObggE8u8J6QMuQAD3ROEkRoADNtCgBjRDJOCmhzwyVu03woAEh+vWh8kfwSkqA

πŸ’» 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

dummdidumm added a commit to sveltejs/svelte that referenced this issue Sep 16, 2024
fixes #13259
fixes #12665 

put it into dts for now because of microsoft/TypeScript#59980

---------

Co-authored-by: Simon Holthausen <[email protected]>
@Andarist Andarist linked a pull request Sep 16, 2024 that will close this issue
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Sep 19, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants