Types issue in zod-openapi in v0.19.4, .5, & .6 (repro attached)
Maybe I'm holding it wrong, but this minimal file reproduces the type error:
12 Replies
Here's the text of the type error
perhaps there's a bug in the fix for this issue š¤ https://github.com/honojs/middleware/issues/1102
GitHub
Variables are of type
never
when there's a middleware with @hono/...Which middleware has the bug? @hono/zod-openapi What version of the middleware? 0.19.2 What version of Hono are you using? 4.7.5 What runtime/platform is your app running on? (with version if possi...
i can't repro on
0.19.4
have you tried restarting your ts server, and/or reinstalling dependencies?got this down to a minimal reproduction sandbox on Stackblitz
Run
npm run typecheck
to see the error (the editor doesn't immediately show the issue until the file is edited)Taylor Beseda
StackBlitz
hono-zod-type-error - StackBlitz
A TypeScript project based on @hono/zod-openapi, @types/node and typescript
Dope. Thanks for putting this together!
Still an issue in v0.19.6 -- I updated the reproduction above āļø and made it even simpler.
npm test
runs a simple typecheck tsc --noEmit --skipLibCheck main.ts
and it complains with the same error that my response shapes are
Maybe if someone can make that pass with a change to the tsc flags/settings?
It seems strange that others wouldn't have this issue, so I must have too simple of a TS setup. maybe?
This is actually an issue with the example in the hono/zod-openapi/README.md
too.
I added the example to my test env. you can run npm t
to see both files error in the same way.
(The Stackblitz built-in typechecker doesn't always catch it, but if you edit the file (add a new line) it fires up.)
https://stackblitz.com/edit/hono-zod-type-error-7phbanny?file=zod-openapi_README.ts&view=editor
I must be doing something really dumb here. It's stripped back to the most minimal setup but I'm still getting a type error for the most important type: the handler response matches the route definition.
Any help appreciated.welp that did it! I added
--strict
to my reproduction and the types pass. thanks for the tip! wonder why that isno idea. looks like some pretty significant updates were made to the typing though
i'd open an issue, if you haven't already
Cool yeah I can do that. I hadn't yet because i figured it was something dumb I was doing, but it does seem like it should work (or error differently) without
strict
it did until ~0.19.3, so worth calling out at least