Nomad
Weird data type when extending context in fetch adapter
Well, in case anyone sees this I managed to figure it out. When starting a new CF project with the react framework template it creates an additional tsconfig (to the three existing ones from vite). This config (
tsconfig.worker.json
) references the following types:
and the first two also need to be referenced in tsconfig.app.json
for the files in the src directory to pick up on it. Adding those two removes the issue and allows the types to be inferred correctly 😄36 replies
Weird data type when extending context in fetch adapter
Because inside the router file the output type is fine: https://i.nomad.lol/2025/03/13/IgnorantConure.png
But when it's imported across into my trpc client file it becomes any: https://i.nomad.lol/2025/03/13/GenuineCockatoo.png
36 replies
Weird data type when extending context in fetch adapter
It did occur to me tho that it might be because the router is defined outside src (because it's defined with the index for cloudflare workers). And the way vite (and cloudflares starter) does it is to split up the tsconfigs
36 replies
Weird data type when extending context in fetch adapter
According to the docs that's how to use it when set up like I have with a simple SPA: https://trpc.io/docs/client/tanstack-react-query/setup#3b-setup-without-react-context
36 replies
Weird data type when extending context in fetch adapter
Gotcha, I tried moving it all to one file, so I've got this (there's some test procedures for KV in there but that's about it):
Unfortunately I still get the same issue:
https://i.nomad.lol/2025/03/13/SelfishAmericancrayfish.png
36 replies
Weird data type when extending context in fetch adapter
It's the way it was done in the guide, here: https://trpc.io/docs/server/adapters/fetch#create-the-context
I simply copy/pasted and adapted to my needs
36 replies