question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

broken compatibility with latest @types/mongodb

See original GitHub issue

Do you want to request a feature or report a bug? BUG mongoose@5.11.16 with @types/mongodb@3.6.7

What is the current behavior?

src/loaders/mongoose.ts:25:5 - error TS2322: Type 'import("node_modules/mongoose/node_modules/@types/mongodb/index").Db' is not assignable to type 'import("node_modules/@types/mongodb/index").Db'.
  Types of property 'collection' are incompatible.
    Type '{ <TSchema = any>(name: string, callback?: import("node_modules/mongoose/node_modules/@types/mongodb/index").MongoCallback<import("node_modules/mongoose/node_modules/@types/mongodb/index").Collection<TSchema>>):...' is not assignable to type '{ <TSchema = any>(name: string, callback?: import("node_modules/@types/mongodb/index").MongoCallback<import("node_modules/@types/mongodb/index").Collection<TSchema>>): import("node_modules...'.
      Types of parameters 'callback' and 'callback' are incompatible.
        Types of parameters 'result' and 'result' are incompatible.
          Type 'import("node_modules/mongoose/node_modules/@types/mongodb/index").Collection<any>' is not assignable to type 'import("node_modules/@types/mongodb/index").Collection<any>'.
            Types of property 'aggregate' are incompatible.
              Type '{ <T = any>(callback: import("node_modules/mongoose/node_modules/@types/mongodb/index").MongoCallback<import("node_modules/mongoose/node_modules/@types/mongodb/index").AggregationCursor<T>>): import("/mnt/c/dev/...' is not assignable to type '{ <T = any>(callback: import("node_modules/@types/mongodb/index").MongoCallback<import("node_modules/@types/mongodb/index").AggregationCursor<T>>): import("node_modules...'.
                Types of parameters 'callback' and 'callback' are incompatible.
                  Types of parameters 'result' and 'result' are incompatible.
                    Type 'import("node_modules/mongoose/node_modules/@types/mongodb/index").AggregationCursor<any>' is not assignable to type 'import("node_modules/@types/mongodb/index").AggregationCursor<any>'.
                      The types returned by 'group(...).addCursorFlag(...).project(...)[Symbol.asyncIterator]()' are incompatible between these types.
                        Type 'AsyncIterableIterator<U>' is not assignable to type 'AsyncIterableIterator<U>'. Two different types with this name exist, but they are unrelated.
                          Type 'U' is not assignable to type 'U'. Two different types with this name exist, but they are unrelated.
                            'U' could be instantiated with an arbitrary type which could be unrelated to 'U'.

reverting to @types/mongodb@3.6.3 does work

If the current behavior is a bug, please provide the steps to reproduce. use mongoose@5.11.16 with @types/mongodb@3.6.7 and use mongodb.Db type in typescript

What is the expected behavior? no typescript error

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version. mongoose@5.11.16 node@14.15.5 typescript@4.1.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
syffscommented, Mar 21, 2021

latest 5.12.x version no longer has the issue

0reactions
vkarpov15commented, Mar 1, 2021

Take a look at your lockfile and make sure all instances of @types/mongodb have the exact same version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compatibility Changes in MongoDB 5.0
Starting in MongoDB 5.0, the serverStatus command does not output opReadConcernCounters , which contained the read concern level specified by query operations.
Read more >
Compatibility Changes in MongoDB 6.0
This page describes changes introduced in MongoDB 6.0 that can affect compatibility with older versions of MongoDB. MongoDB 6.0 is a Major Release, ......
Read more >
Compatibility Changes in MongoDB 3.6
Array Operation Compatibility Changes​​ In 3.4 and earlier versions of MongoDB, the query only returns those documents in which the array field a...
Read more >
Compatibility Changes in MongoDB 4.0
The following 4.0 changes can affect the compatibility with older versions of MongoDB. ... New type conversion operators and enhancements.
Read more >
Release Notes for MongoDB 4.2
Official MongoDB 4.2+ compatible drivers and the MongoDB 4.2 or later mongo shell support explicitly encrypting or decrypting fields with a specific data ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found