andreww2012 / mongoose-zod

A library which allows to author mongoose ("a MongoDB object modeling tool") schemas using zod ("a TypeScript-first schema declaration and validation library").
MIT License
49 stars 7 forks source link

SchemaTypes.Boolean #13

Closed ghostwalkerj closed 8 months ago

ghostwalkerj commented 11 months ago

I have been trying to debug this for a week. Using sveltekit and mongoose 6.6.5 and for some schemas, I am getting this runtime error in the browser

TypeError: Cannot read properties of undefined (reading 'Boolean') From this line in:

var MongooseZodBoolean = class extends M.SchemaTypes.Boolean {
  constructor() {
    super(...arguments);
    this.cast = noCastFn;
  }
};

I thought perhaps a mismatch dependency, but using the same version libs as mongoose-zod. I can't figure out what is making it through this error only on some schemas.

ghostwalkerj commented 10 months ago

I think this has something to do with the polyfills. I am using sveltekit and vite.

andreww2012 commented 8 months ago

Hey, sorry for the late answer. This might be a sign of duplicate dependency (probably there's a default property on M), but it's a bit difficult to be sure without knowing the exact dependencies and the way you're using the library. Please kindly provide a minimal reproduction and I might be able to help you more substantively. Closing this for now.