mongoose-update-if-current icon indicating copy to clipboard operation
mongoose-update-if-current copied to clipboard

[BUG] Recent npm upgrade breaks schema compatibility

Open chongma opened this issue 4 years ago • 2 comments

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'.

ticket.txt

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.

chongma avatar Apr 09 '21 11:04 chongma

Can confirm. Facing the same issue on Ubuntu 20.04.02 with Node v15.0.1 and mongoose 5.12.10

sharmarajdaksh avatar May 25 '21 17:05 sharmarajdaksh

I fixed this and made a PR, im sure its ok to just use ts supression for now.

// @ts-ignore

NHamata avatar Aug 05 '21 20:08 NHamata