Skip to content

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

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

Closed
1 task
lukasbash opened this issue Oct 16, 2024 · 2 comments
Closed
1 task

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

lukasbash opened this issue Oct 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working openapi-react-query Relevant to openapi-react-query

Comments

@lukasbash
Copy link

lukasbash commented Oct 16, 2024

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

@lukasbash lukasbash added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Oct 16, 2024
@drwpow drwpow added openapi-react-query Relevant to openapi-react-query and removed openapi-fetch Relevant to the openapi-fetch library labels Nov 22, 2024
@HagenMorano
Copy link
Contributor

Should be a duplicate of #1845 ?

@kerwanp
Copy link
Contributor

kerwanp commented Dec 19, 2024

Closing as duplicate of #1845

@kerwanp kerwanp closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
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

4 participants