HonoH
Hono6mo ago
Parker

Discriminated Unions from AppType

Hi there! I had a question about the returned type of hc<typeof app>. I have an API route that returns 400 and { success: false, error: SomeTypes } . Generally I would expect this to create a discriminated union on result.ok or on body.success (or both!) but neither seems to work.

This seems to be related to returning c.json() multiple times in my route, but in theory I would expect this to consolidate types.

I've attached some screenshots as an example. In the last screenshot instead of success: boolean it should be a literal, success: false which would allow me to use it as a discriminate. Would love any insight folks have!
image.png
image.png
image.png
Was this page helpful?