peterp
peterp12mo ago

Trying to lazy init "createTRPCProxyClient"

I'm trying to wrap createTRPCProxyClient, but having trouble with the generic. Maybe I'm just a TS idiot, but I thought something like this would work:
export function createTRPC<X extends AnyRouter>(options) {
return createTRPCProxyClient<X>({ links: [/** link stuff */] })
}
export function createTRPC<X extends AnyRouter>(options) {
return createTRPCProxyClient<X>({ links: [/** link stuff */] })
}
I'm getting the following error:
Argument of type '{ links: TRPCLink<X>[]; }' is not assignable to parameter of type 'CreateTRPCClientOptions<X>'.
Type '{ links: TRPCLink<X>[]; }' is not assignable to type 'CreateTRPCClientBaseOptions<X>'.ts(2345)
Argument of type '{ links: TRPCLink<X>[]; }' is not assignable to parameter of type 'CreateTRPCClientOptions<X>'.
Type '{ links: TRPCLink<X>[]; }' is not assignable to type 'CreateTRPCClientBaseOptions<X>'.ts(2345)
What am I not appreciating here?
5 Replies
peterp
peterp12mo ago
@alexkatt halp me dawg
Alex / KATT 🐱
Alex / KATT 🐱12mo ago
@ me on Monday
peterp
peterp12mo ago
@alexkatt '@ing' you 🙂
Alex / KATT 🐱
Alex / KATT 🐱12mo ago
ah yeah this is because we have TS helpers that ensures that you add a transformer in the client if we have it on the server so what are you trying to do with your wrapper? can you make a ts playground and i can help from there?
peterp
peterp12mo ago
Sure!