Skip to content
Source
Sign inSign up
TanStack/query

[svelte-query] `getQueryData`/`setQueryData` fail to infer query data type from `queryOptions` #7535

Send to my agent
Closedstuartin(GitHub profile, opens in a new tab) opened this issue 3 comments

Describe the bug

When using queryOptions both queryClient.getQueryData and queryClient.setQueryData fail to infer query data type and fallback to unknown. I believe this should work based on https://tkdodo.eu/blog/the-query-options-api#datatag ?

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ4DCANsOgHYwA0cAjjvgPJgzARmpwC+cAZlBCDgAiAAIwAhuwkBjANYB6VADd0RGOgC0dXHiEBuAFAHpbVPAjNW7OAF44ACgCUtgHy16eJi1P2EBuO46ANLoeABccADaQgAWqkQQQgC6cOIcJlKU-oH4AGJkEU6uiNkBUOgwyFBkcAAK-CDAGAB05agQRCr2AORxRAndjoYBnFmcQ0YZZjmEJOTwdmhYHsSkFE6GU-AAJuIStjOr880A5hXYOgAie+L2Ft7sTs3a+CF4EwGfcPLyAHoA-EYXrM1jBmhgYBd8NcJHdLD5HM8PG9qPYwOUlKw0M4bG4-GUKlUauj0JiIGhhl8qT8AQZxnogA

Steps to reproduce

  1. Go to typescript playground
  2. Check the return types for queryClient.getQueryData and queryClient.setQueryData

Expected behavior

Types should be correctly inferred from queryOptions the same as Vue and React

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows, Chrome

Tanstack Query adapter

svelte-query

TanStack Query version

5.40.1

TypeScript version

v5.4.5

Additional context

I saw the same report for vue-query here:

https://github.com/TanStack/query/issues/6566

  1. same code works if you change the import to from "@tanstack/react-query", so yes, there is an issue in the queryOptions types of svelte-query. I think we might not have the data tag implemented there. Would you want to take a look contributing this?

  2. TkDodo added labelshelp wanted

  3. TkDodo added labelstypes

  4. TkDodo added labelspackage: svelte-query

  5. TkDodo added labelsgood first issue

  6. @TkDodo Hello, I am sossost, a new contributor. Can I resolve this issue??

  7. TkDodo assignedsossost

  8. TkDodo closed this

  9. Such a quick turnaround. Amazing work 🚀

    Thanks @TkDodo and @sossost 🙏

Sign in to join this conversation.