Can't get the RPC typing
Hey ! Hope you're doing well, I have an issue with the RPC types, how can I manage to get the client types ?
// hc.ts
import router from "./root";
import { hc } from "hono/client";
const client = hc<typeof router>("");
export type Client = typeof client;
export const hcWithType = (...args: Parameters<typeof hc>): Client =>
hc<typeof router>(...args);
const test = hcWithType("http://localhost:3000/api");
// ^? unknown// hc.ts
import router from "./root";
import { hc } from "hono/client";
const client = hc<typeof router>("");
export type Client = typeof client;
export const hcWithType = (...args: Parameters<typeof hc>): Client =>
hc<typeof router>(...args);
const test = hcWithType("http://localhost:3000/api");
// ^? unknown// root.ts
import { Hono } from "hono";
import userRouter from "./services/user";
import todoRouter from "./services/todo";
import { cors } from "hono/cors";
const app = new Hono().basePath("/api");
app.use(
"*",
cors({
origin:
process.env.NODE_ENV === "development" ? "*" : "https://app.example.com",
}),
);
const router = app.route("/users", userRouter).route("/todos", todoRouter);
export default router;// root.ts
import { Hono } from "hono";
import userRouter from "./services/user";
import todoRouter from "./services/todo";
import { cors } from "hono/cors";
const app = new Hono().basePath("/api");
app.use(
"*",
cors({
origin:
process.env.NODE_ENV === "development" ? "*" : "https://app.example.com",
}),
);
const router = app.route("/users", userRouter).route("/todos", todoRouter);
export default router;