RPC AppType breaks if route is defined on a separate file
Hello everyone,
Im trying to build a Hono backend with a Vite SPA as the frontend
Currently the file structure looks like the image attached
I (think) Im able to export the correct type from src/app (image)
If I try to create the RPC client on the backend (for testing), it works as expected (image)
But when I try to import the AppType on the client SPA, it gets imported as Any, thus not working correctly (image)
Ive looked through the discord posts and the GitHub issues, but I could not find someone with this error.
Both tscong.json have strict set to true, as the docs says
Im no TS expert so I cant debug what is happening
I restarted the TS server multiple times, reinstalled Node modules, etc. Nothing worked
Thanks in advance!
6 Replies
I think is related to this issue but im not 100% sure
https://github.com/honojs/hono/issues/1746
GitHub
Absolute imports break
typeof app
for rpc client. · Issue #1746 ·...What version of Hono are you using? 3.10.2 What runtime/platform is your app running on? bun What steps can reproduce the bug? I have a separate file that has a single test route in it // test-rout...
Ok, I was able to debug the issue. Its completely weird
If I have the code of the first image in app.ts, the rpc client works just fine (second image)
But if I define the test route on a separated file on my backed, imported as shown, it stops working. The SAME CODE, just exported on another file
What is happening?
Images
On the issue is mentioned "absolute imports" but im using relative imports and it also does not work
Isn't it a miss configured typescript ?
No idea. It is working now for some reason. I did not change anything in the tsconfig files. I had restarted my editor when i was having the problem but it did not fix it. I restarted my computer and now it works. Typescript things I guess lmao