Skip to content

Typescript issues with query data selector #2899

@sem4phor

Description

@sem4phor

Describe the bug
When I transform data with the query data selector like stated here https://react-query.tanstack.com/guides/migrating-to-react-query-3#query-data-selectors a typescript error is thrown and the type in onSuccess does not change to the type returned in the select function.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/tannerlinsley-react-query-basic-typescript-forked-j8qro?file=/src/index.tsx
  2. Click on 'src/index.tsx'
  3. Scroll down to line 34, hover the error and data in line 31
  4. See error & wrong type

Expected behavior
I expect that the return type of the select function might differ from the original type of the data and the type of the query data, the parameter for onSuccess etc. is overwritten by the type returned from the select function.

Screenshots
image

image

image

Additional context
Sandbox is forked from official TS example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions