I am trying to use ES6 Promises for Mongoose ODM in TypeScrpt.
I have the following line
mongoose.Promise = Promise;
Which give me the following error:
error TS2322: Type 'PromiseConstructor' is not assignable to type 'typeof Promise'.
Type 'Promise<any>' is not assignable to type 'Promise<any>'.
Property 'end' is missing in type 'Promise<any>'.
You are assigning the ES6 Native promise to mongoose promise:
mongoose.Promise = Promise;
You get the error
Property 'end' is missing in type 'Promise'.
Because the native Promise is missing the property end which is present in mongoose Promise (docs https://www.npmjs.com/package/mpromise).
You can either:
ES6 Promise instead of mpromise Or Suppress the error:
mongoose.Promise = Promise as any;
Or not do this entirely :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With