Skip to content

JSDoc return type inference broken for useQuery/createQuery, but not for useMutation/createMutation #7668

Open
@PhilippMolitor

Description

@PhilippMolitor

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions