Skip to content

openapi-react-query select option does not infer types correctly #1949

Closed as not planned
@lukasbash

Description

@lukasbash

Description

The select property of the query options does not infer the type correctly.

Reproduction

Simply return a different type from the select call.
Example:

const { data: firstUser } = QAPI.useQuery(
    "get",
    "/api/users", // endpoint usually returns an array of users, e.g. User[]
    {},
    {
      select: (data) => data[0], // want to return something different here, i.e. User
    },
  );

In this case you get an error from the compiler stating Type User is not assignable to type User[] ...

Expected result

Type inference just works.

Checklist

Metadata

Metadata

Assignees

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