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 return type inference broken for useQuery/createQuery, but not for useMutation/createMutation #7668

Open
PhilippMolitor opened this issue Jul 4, 2024 · 1 comment

Comments

@PhilippMolitor
Copy link

Describe the bug

When typing createQuery and createMutation with jsdoc comments, the return data type gets inferred correctly for the mutationFn, but not for queryFn. If i mistype the data in a query, i will not get a warning. For mutations, that works.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-query-jsdoc?file=src%2Flib%2Ftest.js

Steps to reproduce

Have a look at the stackblitz demo, in the comments it is described how to see that type inference behaves inconsistently.

Expected behavior

queryFn should infer from the attached jsdoc type at createQuery just like createMutation does. Other types of create... could be affected as well.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • macOS latest
  • VSCode 1.91
  • Node 20.15.0

Tanstack Query adapter

svelte-query

TanStack Query version

5.49.0

TypeScript version

Additional context

No response

@lachlancollins
Copy link
Member

Hi @PhilippMolitor , I've tried this with @tanstack/react-query and it has the same limitation. Both share the underlying QueryObserverResult and MutationObserverResult types.

@lachlancollins lachlancollins changed the title svelte-query + jsdoc type inference broken for createQuery, but not for createMutation JSDoc return type inference broken for useQuery/createQuery, but not for useMutation/createMutation Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants