Skip to content

[mongoose.d.ts] Can't use ES6 promises #8248

Closed

Description

@sundriver

Hi Guys,

I am trying to use ES6 Promises for Mongoose ODM in TypeScrpt.

I have the following line

mongoose.Promise = Promise; // as instructed by MongooseJs docs to use ES6 futures

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

I think this could be a bug from .d.ts file of mongoose

Activity

  1. vvakame commented on Feb 26, 2016

    @vvakame
    Member

    umm... I don't have a answer. you can try mongoose.Promise = Promise as any;.

  2. Thomas-P commented on May 14, 2016

    @Thomas-P

    Hi,
    this is a problem, because Promise is not defined on the Mongoose class. Add Promise there and remove the MPromise definition at the bottom of the definition file and it will work as expected.

    I have send a pull request, for this issue #9334

  3. added a commit that references this issue on Jan 22, 2026
    c6757a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions