hono
hono copied to clipboard
Hono RPC client - types inferred incorrectly
What version of Hono are you using?
4.6.2
What runtime/platform is your app running on?
Bun
What steps can reproduce the bug?
export type PreferencesDTO = {
userId: string
newMessages: boolean
newConnectionRequests: boolean
matchSuggestionsOrUpdates: boolean
productUpdates: boolean
createdAt: string
updatedAt: string | null
}
const preferences: PreferencesDTO = {...}
return c.json({
data: preferences
}, 200) ----> The "output" of this gets inferred as "any" in the client:
What is the expected behavior?
Types for the basic JS types are inferred correctly
What do you see instead?
Output type in the RPC client is of type any
Additional information
If you cast your output type like this
return c.json({
data: preferences
}, 200) as {
newMessages: boolean
newConnectionRequests: boolean
matchSuggestionsOrUpdates: boolean
productUpdates: boolean
}
then it's fine, but it's super inconvenient to be forced to cast types like this