RPC typing is behaving weird
I'm not sure if this might be an issue with my setup or with Hono itself, but I'm a bit at a loss here
I have a Hono router for
projects
which I want to use as a projectsClient
with hc
.
For this I take my projects
Router and extract the Type like this:
Now I import ProjectsRouter
in my frontend and my "/" output changes to [x: string]: any;
I thought it might by my Typescript version or any other version but they work fine. Any other type exported from my backend to frontend works too. Anyone might have an idea here?
Thanks in advance!19 Replies
hey! idk if this is what's happening here, but some transpilers are known to elide types when you're exporting them across project boundaries
that means that they'll simplify nested types (or even swallow them entirely)
how are you managing the monorepo, and how are you sharing types across the boundary?
for best performance, you'll want to be exporting generated types
Hey, I‘m using Bun and Turborepo for managing my monorepo and I‘m importing them directly from the source file
How would I go about exporting a generated type and still keep the DX somewhat good?
i've never used turborepo, but here is an example shared previously: https://github.com/m-shaka/hono-rpc-perf-tips-example/blob/main/apps/server/tsconfig.build.json
Found that too, thank you!
Now I have problems with better-auths type being too big, but that's another story!
Thank you very much for your help!
np!
tbh, all this bundling/build stuff is still a bit over my head
Quite honestly, for me too.. It has grown so large it's crazy
my sense is that
better-auth
types probably can be excluded from the generated defs but idk how you'd go about that
i will say i tend to avoid tools like turborepo
, or anything that promises to do it all/manage it for meOkay, wait, now I'm even more confused... This is the type that's getting outputted:
regardless of context, home-rolled tends to be faster, cheaper, and easier
Yeah, for real projects I'd do that too but this is a vacation fun project, just want to do something quick and dirty
sounds like you've definitely got dirty. idk about quick though, lol
but i hear you. i've wasted the last week reinventing the rate-limiting wheel instead of getting a side-project deployed
Curse of programming, should've just booked a vacation instead of doing even more programming lol
porque no los dos?
you could be banging your head against the sand on a beautiful beach
Was an ad-hoc vacation, not really time to plan anything 😄
oh word
what are you working on?
Sorry, had to do something
A translation management system
sick. like for localizing a web page/app? or translating text and/or speech?
Localizing software, yeah, like i18n and other stuff
dope
i feel like it's always an afterthought, which it shouldnt be
but i get that it's also a complicated problem