TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
42.72k stars 2.93k forks source link

Type Error updating TanStack Query version #8230

Closed AngyDev closed 1 month ago

AngyDev commented 1 month ago

Describe the bug

I'm trying to update the TanStack Query version to 5.59.15 but I'm having the following error:

Type 'UseQueryOptions<T, Error, T, QueryKey> & { queryKey: DataTag<QueryKey, T>; }' is not assignable to type 'UseSuspenseQueryOptions<T, Error, T, QueryKey>'.
  Types of property 'queryFn' are incompatible.
    Type 'unique symbol | QueryFunction<T, QueryKey, never> | undefined' is not assignable to type 'QueryFunction<T, QueryKey, never> | undefined'.
      Type 'typeof skipToken' is not assignable to type 'QueryFunction<T, QueryKey, never>'

I tried other versions and it seems that the 5.59.11 version changed something related to the error.

Do you know what is causing the error? Thanks

Your minimal, reproducible example

I don't have any

Steps to reproduce

You can reproduce the error following the snippet below

const [{ data: objects }, { data: containers }] = useSuspenseQueries({
    queries: [
      getAllObjects.getOptions({
        projectId,
      }),
      getAllContainers.getOptions({
        projectId,
      }),
    ],
  });

---

const getAllObjects = createSuspenseQuery<T, { projectId: string }>({
  queryKey: ["objects"],
  fetcher: async (variables): Promise<]T> => {...}
})

Expected behavior

Typecheck doesn't fail

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

Tanstack Query adapter

None

TanStack Query version

5.59.11

TypeScript version

5.6.3

Additional context

We have also tried updating the TanStack query version with the previous version of react-query-kit (2.0.10), but we have the same error.