Nothing Special   »   [go: up one dir, main page]

Skip to content
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

bug: React: Types for callback of trpc.useQueries doesn't allow returning an empty array #6188

Open
1 task
SimonSimCity opened this issue Nov 4, 2024 · 0 comments

Comments

@SimonSimCity
Copy link
SimonSimCity commented Nov 4, 2024

Provide environment information

  System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1
    Memory: 62.41 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 9.12.2 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
  Browsers:
    Chrome: 130.0.6723.92
    Safari: 17.4.1
  npmPackages:
    @tanstack/react-query: ^5.59.19 => 5.59.19 
    @trpc/client: 11.0.0-rc.608 => 11.0.0-rc.608+f75de97b3 
    @trpc/react-query: 11.0.0-rc.608 => 11.0.0-rc.608+f75de97b3 
    react: ^18.3.1 => 18.3.1 
    typescript: ^5.6.3 => 5.6.3 

Describe the bug

I have a query which I just want to run in a certain condition (if another query had a non-empty result). I was trying to follow the docs (see https://trpc.io/docs/client/react/useQueries in conjunction with https://tanstack.com/query/v4/docs/framework/react/guides/dependent-queries#usequeries-dependent-query) but I could not get my code snippet to compile.

Link to reproduction

https://stackblitz.com/edit/github-qa2kdy?file=src%2Fpages%2Findex.tsx

To reproduce

Change the text in the variable text in line 10 of the index.tsx, and you'll see the error appear. To me the error only appeared after changing the text.

Additional information

Here's the typescript error I get on the callback:

Argument of type '(t: UseQueriesProcedureRecord<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }, { greeting: QueryProcedure<{ input: { name?: string | null | undefined; }; output: { text: string; }; }>; }>) => [] | [...]' is not assignable to parameter of type '(t: UseQueriesProcedureRecord<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }, { greeting: QueryProcedure<{ input: { name?: string | null | undefined; }; output: { text: string; }; }>; }>) => readonly []'.
  Type '[] | [TrpcQueryOptionsForUseQueries<{ text: string; }, { text: string; }, TRPCClientError<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }>>]' is not assignable to type 'readonly []'.
    Type '[TrpcQueryOptionsForUseQueries<{ text: string; }, { text: string; }, TRPCClientError<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: false; }>>]' is not assignable to type 'readonly []'.
      Source has 1 element(s) but target allows only 0.(2345)

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant