I recently upgraded to 3.23.x from 3.22.4 and starting getting this error:
TypeError: Cannot read private member from an object whose class did not declare it.
After some digging, I narrowed it down to ZodEnums parsing under specific circumstances. It happens when a ZodEnum has been deep cloned (in this case with lodash) and is then added as value of a ZodObject.
See the reproduction for details and some cases that do and don't work. It's the parsing on the last line that causes the error. Comment it out, and the error goes away.
Edit the package.json to 3.22.4 and the error also disappears.
Reproduction: https://codesandbox.io/p/sandbox/zod-test-d6y6ts
I recently upgraded to 3.23.x from 3.22.4 and starting getting this error:
After some digging, I narrowed it down to ZodEnums parsing under specific circumstances. It happens when a ZodEnum has been deep cloned (in this case with lodash) and is then added as value of a ZodObject.
See the reproduction for details and some cases that do and don't work. It's the parsing on the last line that causes the error. Comment it out, and the error goes away.
Edit the package.json to 3.22.4 and the error also disappears.
I think this might be a related issue: https://github.com/colinhacks/zod/issues/3520
Thanks!