Interface return type in RPC functions for Service / WorkerEntrypoint

I'm trying to implement a RPC Service in my auth service worker that verifies a jwt token, but whenever import an interface type from another file, it infers the return type of the RPC to never. But when I turn that interface into a type instead of interface, it does work, why is that?
2 Replies
ItsWendell
ItsWendellOP9mo ago
I can cast the interface to a format that does work for type inference in the RPC calls:
export type ToType<T> = {
[K in keyof T]: T[K];
};
export type ToType<T> = {
[K in keyof T]: T[K];
};
JFSIII
JFSIII7mo ago
Thanks for this! I am experiencing the same thing and I never would have thought to try type vs interface. I also have a situation where the return type shows undefined for a similar reason. If I use an interface to define the shape, or an unknown for a RHS then it'll break. If I use types and any then works as expected but UGH!
Want results from more Discord servers?
Add your server