What version of Hono are you using?
4.12.2
Reproduction
import { Hono } from "hono";
import { hc } from "hono/client";
const app = new Hono().get("/", (c) =>
Promise.resolve({ hello: "world" }).then((d) => c.json(d)),
);
const api = hc<typeof app>("");
// data has unknown type
const data = await api.index.$get().then((r) => r.json());
But the same code without arrow funcion works:
import { Hono } from "hono";
import { hc } from "hono/client";
const app = new Hono().get("/", (c) => {
const resp = Promise.resolve({ hello: "world" }).then((d) => c.json(d));
return resp;
});
const api = hc<typeof app>("");
// data has { hello: string; } type
const data = await api.index.$get().then((r) => r.json());
What is the expected behavior?
Types should be inferred in both cases
What do you see instead?
RPC json response has unknown type
What version of Hono are you using?
4.12.2
Reproduction
But the same code without arrow funcion works:
What is the expected behavior?
Types should be inferred in both cases
What do you see instead?
RPC json response has
unknowntype