H
Hono•4w 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;
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);
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
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 😦
2 Replies
ambergristle
ambergristle•4w ago
please use syntax highlighting for code snippets also, drizzle should probably be in your backend dir, and hc-client in your frontend dir. pulling them out into separate packages creates more problems than it solves the only thing that really needs to be shared between your two packages is the generated (not inferred) AppType
ForkMeDaddy
ForkMeDaddyOP•3w ago
Alright. I will try it this way

Did you find this page helpful?