Skip to content

'structuralSharing' has incorrect type when combined with 'select' #5806

@levidrain

Description

@levidrain

Describe the bug

When using both select and structuralSharing, structuralSharing is incorrectly typed to the query result instead of the result of the select parameter.

Your minimal, reproducible example

https://www.typescriptlang.org/play?ts=4.9.5#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ4A0c2ueA0uoXAKoYn4DyYMwEAdqnAL5wBmUEEHADkAARgBDDpIDGAawD0UdBJkwAtAEcc+YQG4AsAChjvZGzWs2cAGIQIACgCUiY3Hco6OvA4RuPAdqkFHgAXHAA2gBEcpRRALoE-gHuQfg2bOESqHgWcM5wALwAfHASAO4SwPBRABLoADYNEHAA6tANACZRSUYpHhgN6GrhqDBQRaVjUAB0Q2wA5jAAFr397tPIashQEg0AyssSUMCL4Q4SRABGLiWufesBCgpwbBAsMuhwKxLwK1+oYALNi-HZfCC8b7LYCcGHfPBgdCdb4taanBbXZDwarCTiqGDIPYNPBwMDZDDI-6vZAgK64PgCISDYYwZKPODKAlQaxRKKGB79LhsrhOflcIA

Steps to reproduce

Create a query with both a select and structualSharing. The select should return a different type from the queryFn.

Expected behavior

The structuralSharing function is typed to accept the queryFn return, but is actually passed the select return.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Typescript 4.9.5
  • VS Code

Tanstack Query adapter

react-query

TanStack Query version

4.29.3

TypeScript version

4.9.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions