HonoH
Hono10mo ago
Tony

RPC types not working well inside a monorepo

I have a monorepo setup with packages/api for my hono api and app/www for the client code. I have set up rpc well but i am getting Type instantiation is excessively deep and possibly infinite.ts. I have tried the following
  • I have set strict to true on both my api and client package
  • have set composite true in my api package and set path reference in my client package.
The above two helped to infer the types in the client from unknown to actual types but now its giving the type instantiation error.

Also my routes are chained and splitted accordingly like this
const routes = [
  products,
  prices,
  discounts,
  customers,
  addresses,
  subscriptions,
  transactions,
  keys,
  // checkout,
] as const;


routes.forEach((route) => {
  app.route("/", route);
});
export type AppType = (typeof routes)[number];


now getting the type error here
import app, { type AppType } from "@repo/api";
import { hc } from "hono/client";
const client = hc<AppType>("");
                   //^? type error happens here
Was this page helpful?