francescov1 / mongoose-tsgen

A plug-n-play Typescript generator for Mongoose.
105 stars 25 forks source link

Generic type 'Model<T>' requires 1 type argument #23

Closed www-chique closed 3 years ago

www-chique commented 3 years ago

Right off the bat, I'm new at the whole Typescript and Mongoose, so maybe I am doing something wrong.

I am facing this issue. While using "npx mtgen", it generates UserModel like so

export interface UserModel
  extends mongoose.Model<UserDocument, UserQueries>,
    UserStatics {}

However, the line mongoose.Model<UserDocument, UserQueries> shows an error from ts, which is Generic type 'Model' requires 1 type argument

So when I manually remove "UserQueries", and just use mongoose.Model<UserDocument> instead, everything works just fine. Not sure if it's due to using a more updated version of mongoose, or something.

Any help is appreciated. For now I am manually removing the ***Queries like I mentioned, to make this work.

A side-note: I am a big fan of this tool, and it absolutely makes my work 100 times easier. Much better than the other (sometimes more popular) options out there, which requries you to learn a completely new API just to write the schema, and moreover sometimes it doesn't work. mongoose-tsgen is underrated, and I love the "compiler" approach, it works seamlessly with existing Schema structure.

www-chique commented 3 years ago

Never mind, someone already reported. https://github.com/Bounced-Inc/mongoose-tsgen/issues/19

francescov1 commented 3 years ago

Praise is much appreciated 😊 I had the same experience with the other modules which led me to write this!