[BUG] Recent npm upgrade breaks schema compatibility
Describe the bug A clear and concise description of what the bug is.
I am doing the course https://www.udemy.com/course/microservices-with-node-js-and-react by Stephen Grider which makes use of this plugin. I was recently prompted to upgrade npm and now I get the following stack trace
[orders] [ERROR] 10:42:32 ⨯ Unable to compile TypeScript:
[orders] src/models/ticket.ts(43,21): error TS2345: Argument of type '(schema: Schema<Document<any, {}>, Model<any, any>, undefined>, options?: PluginOptions | undefined) => void' is not assignable to parameter of type '(schema: Schema<TicketDoc, Model<TicketDoc, {}>, undefined>, opts?: any) => void'.
[orders] Types of parameters 'schema' and 'schema' are incompatible.
[orders] Type 'Schema<TicketDoc, Model<TicketDoc, {}>, undefined>' is not assignable to type 'Schema<Document<any, {}>, Model<any, any>, undefined>'.
[orders] Types of property 'methods' are incompatible.
[orders] Type '{ [name: string]: (this: TicketDoc, ...args: any[]) => any; }' is not assignable to type '{ [name: string]: (this: Document<any, {}>, ...args: any[]) => any; }'.
[orders] Index signatures are incompatible.
[orders] Type '(this: TicketDoc, ...args: any[]) => any' is not assignable to type '(this: Document<any, {}>, ...args: any[]) => any'.
[orders] The 'this' types of each signature are incompatible.
[orders] Type 'Document<any, {}>' is not assignable to type 'TicketDoc'.
Line 43 is where the plugin is. The file is ticket.ts which is typescript
ticketSchema.plugin(updateIfCurrentPlugin)
To Reproduce Steps to reproduce the behavior and/or a minimal code sample or link to a repository that reproduces the behavior.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- Platform: Fedora 33
- Node.js version: v14.16.0
- Mongoose version: 5.11.10
Additional context Add any other context about the problem here.
Can confirm. Facing the same issue on Ubuntu 20.04.02 with Node v15.0.1 and mongoose 5.12.10
I fixed this and made a PR, im sure its ok to just use ts supression for now.
// @ts-ignore