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

queryOptions typing errors when calling queryClient methods with ref in query key #7101

Closed
EwenDC opened this issue Mar 13, 2024 · 6 comments · Fixed by #7390
Closed

queryOptions typing errors when calling queryClient methods with ref in query key #7101

EwenDC opened this issue Mar 13, 2024 · 6 comments · Fixed by #7390

Comments

@EwenDC
Copy link

EwenDC commented Mar 13, 2024

Describe the bug

Follow on from #6299. It appears the typing issues persist if your queryKey includes any Ref or MaybeRef values, both nested in objects and at the top level.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/tanstack-query-example-vue-basic-forked-3gchjt?file=%2Fsrc%2FPosts.vue%3A12%2C37

Steps to reproduce

  1. Look at src/posts.vue
  2. An erroneous type error should appear on line 15 but not on line 17

Expected behavior

There should be no typing errors, as we have ensured the query options object is valid by passing it through the queryOptions function.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: MacOS 14.3.1 (23D60)
  • Browser: Chrome Version 122.0.6261.112 (Official Build) (arm64)

Tanstack Query adapter

vue-query

TanStack Query version

v5.27.5

TypeScript version

v5.1.6

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 15, 2024

sandbox is private, I cannot access it

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 15, 2024

if you have a typing issue, please just provide a typescript playground, that's so much easier:

https://www.typescriptlang.org/play

@EwenDC
Copy link
Author

EwenDC commented Mar 16, 2024

Apologies, I did not realise the sandbox was set to private by default, I have made it public. I did not provide a TypeScript playground link because I was struggling to replicate the issue there. However now that I understand it better I can also provide a link to that too:
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzlApgMzgXzmqERwDkAbgK4qEBQoksicAjuVAJ4DyYMwEAdgM4AaOKT4oAisxYBhADbAUPGEJHjJWHHgKEAAjACG-fQGMA1gHoyKALRMUrKpSO8+8W61nzFcALzDREu2k5BRgACgBKR2d4SBcASQATH2R0UIBGSKdDOD0EkGAeAFkIBJRk1DRQmChySKjs2JgA1mS3dk5uflCESjg+xkkAaRQWAC44AG1CAAUIF0IhRsSAXUpMTOi-O2aWVskOLmdu3v624bHJwgBVUSgF+lz8opKyzFX1ykoVHdDGncjvpJQiooP9Pm0PCEAHRoFAwIwACx+f0kkQhwUUMLhiJ+ILBQA

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 16, 2024

@DamianOsipiuk FYI

@ilajosmanov
Copy link

agree, face the same problem :(

@EwenDC
Copy link
Author

EwenDC commented May 9, 2024

Thank you for the fix @DamianOsipiuk! This allows us to adopt the much better queryOptions() pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants