ClientResponse<T>.json()
returns never
when T
is a union type of structurally different objects
#1783
Labels
ClientResponse<T>.json()
returns never
when T
is a union type of structurally different objects
#1783
What version of Hono are you using?
3.11.2
What runtime/platform is your app running on?
Found on Bun (v1.0.15) initially, reproduced on Deno (v1.38.4)
What steps can reproduce the bug?
Hi, thanks for building Hono!
I ran into an unexpected behavior when trying to use
ClientResponse.json()
. In the following minimal reproduction, the type information is lost, we getnever
.What is the expected behavior?
I expected the type to be
OkResponse | ErrorResponse
.Explicitly typing the handler 's return value does not help.
What do you see instead?
Additional information
It seems that the type breaks only on union of object (record) types:
I suspect it has something to do with the signature of
ClientResponse.json()
:Promise<BlankRecordToNever<T>>
.Is this an expected behavior?
The text was updated successfully, but these errors were encountered: