Skip to content

Conversation

@DiederikvandenB
Copy link
Contributor

This PR fixes the issue outlined in #2099.

I noticed that prefetchInfiniteQuery did not have any generic types. Was this done on purpose, and if not, need they be added?

@vercel
Copy link

vercel bot commented Apr 8, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/A1u8qpLtyeHDNM36twkhujKjADEq
✅ Preview: https://react-query-git-fork-diederikvandenb-master-tannerlinsley.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 8, 2021

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:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

Copy link
Collaborator

@TkDodo TkDodo left a 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.

@DiederikvandenB
Copy link
Contributor Author

DiederikvandenB commented Apr 8, 2021

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');
})

@TkDodo
Copy link
Collaborator

TkDodo commented Apr 8, 2021

yes, that looks good 👍

@DiederikvandenB
Copy link
Contributor Author

Alright, I've updated the PR. Note that I force pushed a commit over the first one. This one contains generic types for prefetchInfiniteQuery too.

The tests for the four functions have been added too.

@TkDodo TkDodo merged commit 356627a into TanStack:master Apr 8, 2021
@tannerlinsley
Copy link
Member

🎉 This PR is included in version 3.13.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants