SpoonmanS
tRPC13mo ago
Spoonman

Inconsistent types for mutation return type

I have a
signIn
mutation that returns:

{
  accessToken: string;
  refreshToken: string;
}


  1. When I pull the types from the
    AppRouter
    in the server (separate API with Express.js), the proper type is inferred.
  2. When I pull the types of the mutation from the
    AppRouter
    , but this time from my client, the wrong type is inferred (I get
    never
    instead of
    string
    for both keys)
  3. When I pull the types via
    Awaited<ReturnType<typeof trpc.signIn.mutate>>
    or by directly invoking the function, the type turns to
    {}
See screenshots for some more details.

These are the packages I have installed:

"@tanstack/react-query": "^5.61.0",
"@trpc/client": "^11.0.0-rc.643",
"@trpc/react-query": "^11.0.0-rc.643",
"@trpc/server": "^11.0.0-rc.643",


Why are my mutation output types getting lost? Thanks!
Screenshot_2024-11-30_at_11.07.33_AM.png
Screenshot_2024-11-30_at_11.11.05_AM.png
Screenshot_2024-11-30_at_11.11.17_AM.png
Was this page helpful?