Nick
Nick14mo ago

TRPCContextState not found in v10

In our v9 app, we used TRPCContextState from internals to type out TRPC utils, importing it like import { TRPCContextState } from '@trpc/react-query/dist/declarations/src/internals/context'; and using it in types like trpcUtils: TRPCContextState<AppRouter, any>; Is there a quick alternative to this? Can't find it in the the latest trpc10 code packages.
6 Replies
Alex / KATT 🐱
Alex / KATT 🐱14mo ago
I can't remember what that was used for, could you elaborate on what you need it for?
Nick
Nick14mo ago
Typing out trpc.utils maybe, it is hard to tell. The interfaces I see it in are very type-happy Yeah, I'm seeing it used as a type for trpc.useContext() perhaps a better question: is there a type we can use for trpc.useContext() in trpc 10?
Alex / KATT 🐱
Alex / KATT 🐱14mo ago
What's the functionality you need to abstract? If you show me the fns you have created in v9 it'd be easier to give guidance What sort of helpers are you making?
Nick
Nick14mo ago
We're putting trpc.utils in ReactContext state, so we've been using TRPCContextState for trpc.utils in ReactContext interface
Alex / KATT 🐱
Alex / KATT 🐱14mo ago
You could just use typeof trpc.utils then for your type, right?
Nick
Nick14mo ago
Thanks Katt, that does it... seems so obvious now 😂