Open james-yeoman opened 1 year ago
I have exactly the same issue, did you find a way to fix it?
I pinned the version of zod across my monorepo using the resolutions
map in the root package json
E.g.
// <repo root>/package.json
{
//...
"resolutions": {
"zod": "^3.x.x"
}
}
// <repo root>/packages/api/package.json
{
//...
"dependencies": {
//...
"zod": "*"
}
}
// <repo root>/packages/shared/package.json
{
//...
"dependencies": {
//...
"zod": "*"
}
}
which ensured everything, including dependencies that use zod, use the most up-to-date, same version. You could always pin the zod version to a specific one if you needed to
I started using
zod
in one of the packages in my team's monorepo, and everything was great. Thezod
version that Yarn installed wasv3.22.2
.I then add
zod
to another package in my team's monorepo and it's still great. At this point,v3.22.4
is released, and Yarn chooses to install that version.I then import a
zod
schema from the first package into the second package, try to use it to create a new schema, and the typescript server freaked out.Here's an exerpt from my
tsserver.log
(manually prettified)where
Declaration
is the schema I was constructing inroot.schema.ts
, using an import from@lll/shared
.It's worth noting, that error appeared only when adding a field to the object schema that used a schema from
@lll/shared
.