saisilinus / node-express-mongoose-typescript-boilerplate

A boilerplate for making production-ready RESTful APIs using Node.js, TypeScript, Express, and Mongoose
MIT License
325 stars 93 forks source link

Paginate: (schema: Schema) type error #30

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi, I'm updated all package for this project, but after update mongoose i get error type, please check issue and if you can helped to fix this problem.

user.model.ts(58,19): error TS2345: Argument of type '(schema: Schema) => void' is not assignable to parameter of type 'PluginFunction<IUserDoc, IUserModel, any, any, any, any>'. [0] Types of parameters 'schema' and 'schema' are incompatible. [0] Type 'Schema<IUserDoc, IUserModel, any, any, any, any, "type", IUserDoc>' is not assignable to type 'Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { [x: string]: any; }>'. [0] Types of property 'obj' are incompatible. [0] Type '{ _id?: SchemaDefinitionProperty | undefined; __v?: SchemaDefinitionProperty | undefined; id?: SchemaDefinitionProperty | undefined; ... 5 more ...; isEmailVerified?: SchemaDefinitionProperty<...> | undefined; }' is not assignable to type '{ [path: string]: SchemaDefinitionProperty; } | { [x: string]: SchemaDefinitionProperty | undefined; }'. [0] Type '{ _id?: SchemaDefinitionProperty | undefined; __v?: SchemaDefinitionProperty | undefined; id?: SchemaDefinitionProperty | undefined; ... 5 more ...; isEmailVerified?: SchemaDefinitionProperty<...> | undefined; }' is not assignable to type '{ [x: string]: SchemaDefinitionProperty | undefined; }'. [0] Property 'isEmailVerified' is incompatible with index signature. [0] Type 'SchemaDefinitionProperty' is not assignable to type 'SchemaDefinitionProperty | undefined'. [0] Type 'false' is not assignable to type 'SchemaDefinitionProperty | undefined'.

saisilinus commented 1 year ago

Please use an issue template so that your problem can be more descriptive

saisilinus commented 1 year ago

I am not sure what the problem is but I know that MongoDB has introduced several breaking changes. I recently worked on a project where I was using the JavaScript MongoDB driver and I had to recode the MongoDB code. The good thing is that your error is descriptive and the MongoDB docs are helpful. I guess the breaking changes introduced by MongoDB also led to breaking changes in Mongoose. I advise you to either rollback to the previous Mongoose version or update your code to fix the errors. I currently don't have plans to update the Mongoose version in this repository though I'd be happy to review a pull request on the issue.