procedure output is "any"
I have a problem with the procedure output type. Procedure input types are all correct, but the output type is "any."
The server type is correct, but not on
inferRouterClient<AppRouter>
I'm using 11.0.0-rc.648
and zod ^3.23.8
here's what I got
inferRouterClient<AppRouter>
register procedure
14 Replies
i guess this is a bug?
FAQ / Troubleshooting | tRPC
Collection of frequently asked questions with ideas on how to troubleshoot & resolve them.
yes, i read that article before, and I'm still getting "any"
tsconfig.json
package.json
i guess something to do with ts Serialize
i try Serialize<{ a: number }>
got any
I also got this error inside Serialize
Bump typescript
"Make sure you are using the TypeScript-version required by tRPC (>=5.6.2)"
I'm getting this as well
Bumped TS to 5.7 and still having issues
@stu looking deeper I've also got the issue with
AsyncIterable
- it doesn't seem to like infer
So it was only that the TS version meant that you can remove the final two type args but that doesn't fix it
Tried messing around with versions (was on v11 - downgraded to v10) no luck
AH OK
The downgrade worked - if you downgrade to v10 and downgrade TS to the appropriate version then delete and reinstall your node_modules
, I've got mine back
It's workingRead this @TechnoWill, was likely that your vscode/cursor wasn't configured to the latest ts version if it was a v11 issue
I did do that and reset it - but willing to assume that it's my local env lol
Will probably figure out again if I can dedicate more time to it
[edit 2: see potential fix below]
[edit as i've made a simpler version with just a single healthcheck function]
New to this so apologies if better to post elsewhere! But to confirm that i'm getting this same issue (incl. trying all the troubleshooting steps above) and i don't think it's a setup thing as client typing is working perfectly except output typings.
using react query integration on client and fastify on server, versions:
"@trpc/client": "^11.0.0-rc.682",
"@trpc/react-query": "^11.0.0-rc.682",
"@trpc/server": "^11.0.0-rc.682",
"typescript": "^5.7.2"
Pics 1 & 2 are server: show healthcheck procedure output is correctly typed as string
Pic 3 is instantiation in client, correctly typed as string output
Pic 4: healthcheck has lost the typing
Any questions just let me know 🙂
[Edit] - ignore below, it was indeed Cursor not picking up TS changes until hardcoding TS version into settings.
Followup: I think i've found a possible solution
If I locally change
node_modules/@trpc/react-query/dist/createTRPCReact.d.ts
type DecorateRouterRecord
output type from inferTransformedProcedureOutput<TRoot, $Value>
to inferProcedureOutput<$Value>;
the error is resolved and i get the right type inferred (see pic 1). It also seems to match the type you use above (i.e. the input isn't called transformed, whilst the output was)This issue was still most likely that your editor wasn't using the latest ts version
Sadly for past me, you're right, so thank you - Cursor wasn't picking up any of the TS changes until I manually hardcoded some settings. Thanks for the patience (and at least i now know more about tRPC under the hood)
Could you please be a hero and make an issue over in cursor issue tracker and ask them to bump their default version? Everyone using trpc will have the issue
Will do, cheers!