HonoH
Hono•8mo ago
ForkMeDaddy

The inferred type of 'client' cannot be named without a reference to

Hono bros I need your help with a problem I can't figure out.

My setup is a monorepo with this stucture. I have done this way to avoid leakage of server code into my frontend code.

root
/apps
/backend
/server
/packages
/hc-client (to avoid server leakage code)
/drizzle


server/src/app.tsx

import { Hono } from "hono";
import { auth } from "./auth";
import { uploadRoute } from "./routes/upload";
import type { AppVariables } from "./types";

export const app = new Hono<{ Variables: AppVariables }>();

app.on(["POST", "GET"], "/api/auth/**", (c) => auth.handler(c.req.raw));

export const routes = app.route("/", uploadRoute);
export type AppType = typeof routes;


hc-client/src/index.ts
import { AppType } from "@repo/backend/app";
import { hc } from "hono/client";

const client = hc<AppType>("");
type Client = typeof client;

export const hcWithType = (...args: Parameters<typeof hc>): Client =>
  hc<AppType>(...args);


And here I have an error on the client:

he inferred type of 'client' cannot be named without a reference to '@repo/backend/node_modules/@aws-sdk/client-s3/dist-types/index.js'. This is likely not portable. A type annotation is necessary


So far I have not found a solution to this 😦
Was this page helpful?