Skip to content

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

Open
@mpash

Description

@mpash

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-react-queryRelevant to openapi-react-query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions