Closed vladshcherbin closed 10 months ago
Interoperability with zod is not our goal.
@koskimas same thing happens with a plain object type, I just happened to found out with a zod one.
This will create same results:
type Brand = {
slug: string
[key: string]: unknown
}
I can create a new issue without zod if needed 😅
You should provide a reproduction with https://kyse.link/
@thelinuxlich thanks, will do 🙌
I've opened a new issue without zod with reproduction, kyse.link is insanely good 🤩
Hey 👋
I have a JSON column and zod validated data is stored there. Same zod schema type is used in database
JSONColumnType
. Schema is a zodobject
type and everything works correctly.When I add .passthrough() to object (
passthrough
is used for preserving unknown keys, specified ones always exist), Kysely loses the ability to getref
.key
suggestions and result output type also has| null
added.Working Reproduction:
Result:
✅
SlugKey
has correct type✅
ref
.key
has correct type suggestions✅ query result has correct type
Non-working:
Just one change to the above code:
Result
✅
SlugKey
still has correct type❌
ref
.key
has no type suggestions❌ query result has incorrect type (
slug
always exists)I've also tried using just
ColumnType
but the result is the same.passthrough
Brand
object type:kysely - 0.27.2 zod - 3.22.4 typescript - 5.3.3 node - 20.10.0 vscode - 1.85.2