type wizard help needed for my fake trpc package
I kinda gave up on tRPC with app router cuz I got frustrated BUT I really like using tRPC. I appreciate that it's organized (but not too restrictive like a rest server) and the method by which inputs are passed and parsed.
As such, I started working on a way in my app to define things almost exactly like a trpc router/procedure so that you still get input parsing with zod, type safety updates on definition and caller side, but just without the trpc stuff. At this point it's not even worth it, but I'm too invested and want it to work. This is majority of the code
which can then be used like this (where i nest it a few times)
this works surprisingly well, however, it's not inferring return type properly. I just get
unknown
, which makes sense since my fn types define the return as such. Anyone have thoughts?1 Reply
chatgpt gave me a working solution that creates some sort of
UnpackPromise
type and then casts with as
. Not sure if this is optimal though, definitely looking for feedback