Closed QuentinRoy closed 1 year ago
Hello, this is definitly not a bug in zodios but a bug with typescript since zodios types are perfectly exported and compatible with mjs. For now it seems to be an issue with types not getting fully inferred accros imports.
Hi,
If I may, I believe you discarded this issue a bit too promptly. I was skeptical so I took the liberty to do some quick digging.
import { IfEquals, Narrow } from '@zodios/core/lib/utils.types';
from index.d.ts
is not exported from @zodio/core
.
Adding the following in the exports
of @zodios/core
's package.json
solves the issue. I am not sure this is how you want to proceed, but I am going to make the PR.
"./lib/*": {
"types": "./lib/*",
"import": "./lib/*.mjs",
"require": "./lib/*.js"
}
Cordialement
PS : I thought "types"
always had to come last in exports
, but it does not seem like TS cares anymore. I am not sure if that's an awkward limitation that has been removed since, or if there might be some hidden incompatibilities somewhere.
thank you for diging this up. that was bad conclusion on my side. PR is welcomed.
This is now fixed on @zodios/core
v10.7.5
, thank you again for taking the time to investigate further. really appreciate the effort and kind the way you handled me closing this too fast.
To evoid it to happen again, i let you close if you confirm v10.7.5
fixes it (worked on my side)
It does seem fixed on my side. Thanks!
ZodiosApp
(or router) isn't properly typed when using modern module resolution strategies. When setting typescript's module resolution to "Node16" (which seems increasingly required as libraries adopt mjs), the app methods (app.get
,app.post
, etc) are of typeany
, and consequently so are the response and request parameters.Here is a minimally reproductible example: https://gist.github.com/QuentinRoy/0f129f6e0e087b7188db0441af854e91.