Skip to content

useInfiniteQuery's select option does not infer correct type #2258

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

Open
1 task done
mpash opened this issue Apr 21, 2025 · 0 comments
Open
1 task done

useInfiniteQuery's select option does not infer correct type #2258

mpash opened this issue Apr 21, 2025 · 0 comments
Labels
bug Something isn't working openapi-react-query Relevant to openapi-react-query

Comments

@mpash
Copy link

mpash commented Apr 21, 2025

openapi-react-query version

0.3.1

Description

useInfiniteQuery does not infer the type from the select option the same way useQuery does. See #2105.

Reproduction

$api.useInfiniteQuery(
  'post',
  '/api/v1/events',
  {},
  {
    select: (data) => data.pages.flatMap((page) => page.data),
  }
)

Produces this error:

Type '(data: InfiniteData<{ data: { id: string }[]; }, unknown>) => { ...; }[]' is not assignable to type '(data: InfiniteData<{ data: { id: string; }[]; }, unknown>) => InfiniteData<...>'.

Expected result

The select type should infer the type for data exactly as useQuery would.

Extra

@mpash mpash added bug Something isn't working openapi-react-query Relevant to openapi-react-query labels Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-react-query Relevant to openapi-react-query
Projects
None yet
Development

No branches or pull requests

1 participant