Skip to content

Typing problem with tanstack-query "select" transformation #963

@ymc9

Description

@ymc9

Tanstack-query supports transforming query results using the "select" operator:

https://tanstack.com/query/latest/docs/react/guides/migrating-to-react-query-3#query-data-selectors

However, using "select" with ZenStack-generated hooks causes typing errors.

useFindFirstUser({}, { select: (data) => data.name});
Type '(data: GetResult<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: Date | null; password: string | null; name: string | null; image: string | null; }, unknown> & {} & { ...; }) => string | null' is not assignable to type '(data: GetResult<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: Date | null; password: string | null; name: string | null; image: string | null; }, unknown> & {} & { ...; }) => GetResult<...> & ... 1 more ... & { ...; }'.
  Type 'string | null' is not assignable to type 'GetResult<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: Date | null; password: string | null; name: string | null; image: string | null; }, unknown> & {} & { ...; }'.
    Type 'null' is not assignable to type 'GetResult<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: Date | null; password: string | null; name: string | null; image: string | null; }, unknown> & {} & { ...; }'.
      Type 'null' is not assignable to type 'GetResult<{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: Date | null; password: string | null; name: string | null; image: string | null; }, unknown>'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions