Type instantiation error when using exported Hono RPC types across different directories #3712
Closed
student-101
started this conversation in
General
Replies: 1 comment
-
Solved! I wanted to share the solution in case anyone encounters the same issue. The problem was caused by two factors:
After fixing these two issues, the type inference works correctly across directories as expected. Thanks for the great RPC functionality in Hono! I'm closing this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm encountering a TypeScript error when trying to use Hono's RPC functionality across different directories. The same code works fine when the client is in the same file as the endpoint definition, but fails with a "Type instantiation is excessively deep and possibly infinite" error when the type is exported and used in another directory.
One of Hono's great features is supposed to be its ability to share types between backend and frontend without explicit type definitions, but I'm unable to achieve this across directories.
Here's a working example (same file):
But when I try to use it across directories:
I know I could work around this by explicitly defining types in a shared types file, but that defeats one of the main benefits of Hono's RPC functionality. Is this a known limitation? Are there any solutions that preserve the automatic type inference across directories?
Environment:
Beta Was this translation helpful? Give feedback.
All reactions