-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(types): adds queryKey generic to queryClient functions #2100
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
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/tannerlinsley/react-query/A1u8qpLtyeHDNM36twkhujKjADEq |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit bc91d03:
|
TkDodo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, thank you. A test that calls those functions with a strict query key just to see that it doesn't type-error would be awesome.
|
Before I implement the rest of the tests, I just quickly wanted to check whether this is what you're looking for, cause I'm not a 100% sure what you mean: test('should not type-error with strict query key', async () => {
type StrictQueryKey = ['strict', string];
const key: StrictQueryKey = ['strict', queryKey()];
const fetchFn: QueryFunction<'data', StrictQueryKey> = () => (
Promise.resolve('data')
);
await expect(
queryClient.fetchQuery(
key,
fetchFn,
)
).resolves.toEqual('data');
}) |
|
yes, that looks good 👍 |
|
Alright, I've updated the PR. Note that I force pushed a commit over the first one. This one contains generic types for The tests for the four functions have been added too. |
|
🎉 This PR is included in version 3.13.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR fixes the issue outlined in #2099.
I noticed that
prefetchInfiniteQuerydid not have any generic types. Was this done on purpose, and if not, need they be added?