-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Method getQueriesData does not return correct type #8613
Comments
This situation is mentioned in the docs https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientgetqueriesdata
So you could type the data by doing something like |
Yes, it is. But this mentioned is pretty old and being writed before we get UPD. |
getQueriesData is fuzzy, so even if you pass a key from queryOptions, there is no guarantee that the results will have only that type. You could have an entry with a different type that matches the key filter e.g. because it starts with the same key. |
@TkDodo UPD. |
Describe the bug
Method getQueriesData does not return correct type. I tried to use it with queryOptions or infiniteQueryOptions, but returned type is always unknown.
Your minimal, reproducible example
https://www.typescriptlang.org/play/?ssl=20&ssc=30&pln=20&pc=44#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ4A0c2ueAwgDbDoB2MRAjjvgPJgzAQ2pwC+cAMygQQcAOQABGAENuMgMYBrAPRR00+TAC0TUmICwAKCPyuqeLvyVqdOAF44NdAHdizclVowAFAEojJmbw8tKw2LIcMHhsHGb2cJbR7Jzc3ghGcAnuANLoeABccADaAEQhsAD6TBHAUSUAugQZWaQAYjSF0qh4NPJwfvYAfIjNmWowyFA0cCUgeABq0hQ4Jc28TYa8-saGpnIt+PFoWO7e5TDhdLVJsdzbRokAdAAm0jJGysqZmQB6APwBXZBOCvGQASRoAlwame8US1i8jwA5ugLu4ACJvaRnUJompRGIpVCPRK5PDbT7fOD-QF7cwgrEAFXQ9Ic8M8dGRqJIUGoqExMjSpLyhXOl0iNyJJJyeS2Hy+33+QA
Steps to reproduce
Check dataTest variable type. It's incorrect
Expected behavior
Type shold be like dataInferred vatiable, but not unknown.
How often does this bug happen?
None
Screenshots or Videos
Platform
Any platform
Tanstack Query adapter
react-query
TanStack Query version
5.28.13
TypeScript version
5.7.3
Additional context
No response
The text was updated successfully, but these errors were encountered: