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

Vue refs aren't unwrapped in query key type in query context #4387

Closed
henribru opened this issue Oct 26, 2022 · 1 comment · Fixed by #4410
Closed

Vue refs aren't unwrapped in query key type in query context #4387

henribru opened this issue Oct 26, 2022 · 1 comment · Fixed by #4410
Labels
bug Something isn't working package: vue-query types

Comments

@henribru
Copy link
Contributor

henribru commented Oct 26, 2022

Describe the bug

This is the same bug as DamianOsipiuk/vue-query#191. It was fixed in vue-query 1 but seems to have resurfaced in @tanstack/vue-query (haven't checked if was present in the vue-query 2 betas). Essentially the issue is that if you put a ref in the query key, that ref gets unwrapped at runtime, but this isn't reflected in the types.

Copied description from the old issue:

If you do something like:

useQuery(
  ["foo", { bar: ref("bar") }] as const,
  ({ queryKey: [, params] }) => (console.log(params), queryFunc())
);

The type of params will be

{
    readonly bar: Ref<string>;
}

But at runtime the refs are unwrapped so this will just print Object { bar: "bar" }

Your minimal, reproducible example

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ5wC+cAZlBCHAEQACMAhgHaoMDGA1gPQBuOAtAEcc+KgG4AUKEixEcKOhJFS5SlV7ox48SWSNWMYBEZwhuPADFdrABQBKRIS1oswvNfFw4AbSokIEKgAaWQAjeigALjkFayowqCp7QgBdOHpUOFYjFkCPOGskU3wAaXQ8KK9gsHD6EFRUwnsAXgA+fKzmCAAbdAA6LogAc2tqqFrUW2Ciiys7W3FbUSA

Steps to reproduce

Just hover over the params type in the Typescript playground

Expected behavior

The ref should be unwrapped in the type

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Not relevant

react-query version

4.13.3

TypeScript version

4.8.2

Additional context

No response

@henribru
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package: vue-query types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants