tRPCttRPC
Powered by
SpoonmanS
tRPC•15mo ago
Spoonman

Inconsistent types for mutation return type

I have a
signIn
signIn
mutation that returns:

{
  accessToken: string;
  refreshToken: string;
}
{
  accessToken: string;
  refreshToken: string;
}


1. When I pull the types from the
AppRouter
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
AppRouter
, but this time from my client, the wrong type is inferred (I get
never
never
instead of
string
string
for both keys)
3. When I pull the types via
Awaited<ReturnType<typeof trpc.signIn.mutate>>
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",
"@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
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Mutation type issue
OutisOOutis / ❓-help
4y ago
Dynamic return type
OkanOOkan / ❓-help
3y ago