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

useInfiniteQuery typing issues #390

Closed
ivancuric opened this issue Apr 23, 2020 · 2 comments
Closed

useInfiniteQuery typing issues #390

ivancuric opened this issue Apr 23, 2020 · 2 comments
Labels

Comments

@ivancuric
Copy link

https://codesandbox.io/s/youtube-react-query-2848d?file=/src/App.tsx

const getPopularVideos: (key: string, pageToken?: string | undefined) => Promise<gapi.client.youtube.VideoListResponse>
No overload matches this call.
  The last overload gave the following error.
    Argument of type '(key: string, pageToken?: string | undefined) => Promise<gapi.client.youtube.VideoListResponse>' is not assignable to parameter of type 'AnyVariables'.
      Type '(key: string, pageToken?: string | undefined) => Promise<gapi.client.youtube.VideoListResponse>' is not assignable to type 'readonly [any, ...any[]]'.ts(2769)

What's even weirder is how TS correctly infers the usage, but then complains about implicit any:

(parameter) lastGroup: gapi.client.youtube.VideoListResponse
Parameter 'lastGroup' implicitly has an 'any' type.ts(7006)

The function is working fine when used with the regular useQuery.

@amanolar94
Copy link

amanolar94 commented May 22, 2020

@ivancuric it is not a fix of course but I was able to bypass the issue by changing this:
const { data: actions = [] } = useInfiniteQuery( params && ["actions", params], getActions ) to this: const { data: actions = [] } = useInfiniteQuery(params && "actions", () => getActions(params) ) and removing the key parameter from the getActions function

EDIT: For some reason tha data are not returned and the status is kept in loading

@tannerlinsley
Copy link
Collaborator

I'm marking this issue as stale. PRs to improve the types are always welcome!

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

No branches or pull requests

3 participants