wyrd
wyrd
HHono
Created by wyrd on 5/5/2025 in #help
Why does .openapi(route, handler) return unknown type in client.ts when using OpenAPIHono?
I’m new to Hono and trying out @hono/zod-openapi for the first time. Im trying out the RPC feature with client.ts I noticed that when I define my routes like this
const app = new OpenAPIHono()
app.openapi(getTodosRoute, (c) => {
// handler logic
})
const app = new OpenAPIHono()
app.openapi(getTodosRoute, (c) => {
// handler logic
})
client is type unkown But when I chain the .openapi(...) calls like this:
const app = new OpenAPIHono()
.openapi(getTodosRoute, async (c) => { /* handler */ })
.openapi(getTodoByIdRoute, async (c) => { /* handler */ })
const app = new OpenAPIHono()
.openapi(getTodosRoute, async (c) => { /* handler */ })
.openapi(getTodoByIdRoute, async (c) => { /* handler */ })
the types are inferred correctly in client.ts. Why is there a difference? Is this expected behavior with OpenAPIHono, or am I missing something in how route types are collected? Here is my full code https://pastebin.com/dyeYHung
17 replies