Open bennettcolecohen opened 5 days ago
Hey! I looked into this, and it is a known issue:
https://github.com/honojs/middleware/issues/587
https://github.com/honojs/middleware/issues/181
A manual work around would be to add a satisfies constraint... this is not ideal though as it kind of defeats the purpose of types flowing through
Ahh yeah that’s better than my workaround anyway though. Regardless, appreciate this template and tutorial! My team is going to be using it in prod for a new API so should be fun
On Fri, Nov 22, 2024 at 3:33 PM CJ @.***> wrote:
Hey! I looked into this, and it is a known issue:
honojs/middleware#587 https://github.com/honojs/middleware/issues/587
honojs/middleware#181 https://github.com/honojs/middleware/issues/181
A manual work around would be to add a satisfies constraint... this is not ideal though as it kind of defeats the purpose of types flowing through
Screenshot.2024-11-22.at.4.33.07.PM.png (view on web) https://github.com/user-attachments/assets/29828b6d-93e6-4cf4-8c11-886808aa0a59
— Reply to this email directly, view it on GitHub https://github.com/w3cj/hono-open-api-starter/issues/17#issuecomment-2495097553, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVDKAZPHFF2OQHLCA3QIT2T2B65N3AVCNFSM6AAAAABSKBDEY2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVGA4TONJVGM . You are receiving this because you authored the thread.Message ID: @.***>
Hey CJ - I'm trying to better understand how to use Zod OpenApi Hono. The example below shows my
route.ts
schema andhandler.ts
handler.If the response schema in
handler.ts
is missing a required parameter from the schema, a type error correctly shows. Ex: missing validField1. However, a type error is not shown for additional fields. Below, invalidField is allowed to pass and type safety isn't enforced. Why is this? I've also shown my types below.Are there any glaring issues that I should implement to get this working properly?? Thanks in advance! If this is a bug, is there a workaround? Right now, a hack is to just first create the output object with the proper type and then just return it, but there's nothing beyond my willpower preventing me from messing it up. Thanks!
Code below