TS Compilation errors when using Mongo Seeding along MongoDB driver v4
See original GitHub issueI am using mongo-seeding
and mongoose
in the same (typescript) project. I recently upgraded mongoose
to version 6.0.4. This version of mongoose
depends on mongodb
4.1.1 which does not play nicely with mongo-seeding
right now.
node_modules/mongo-seeding/dist/config.d.ts:3:10 - error TS2305: Module '"mongodb"' has no exported member 'CollectionInsertManyOptions'.
3 import { CollectionInsertManyOptions, MongoClientOptions } from 'mongodb';
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/mongo-seeding/dist/database/database.d.ts:1:14 - error TS2305: Module '"mongodb"' has no exported member 'CollectionInsertManyOptions'.
1 import { Db, CollectionInsertManyOptions, MongoClient } from 'mongodb';
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/mongo-seeding/dist/database/database.d.ts:32:167 - error TS2694: Namespace 'node_modules/mongodb/mongodb"' has no exported member 'InsertWriteOpResult'.
32 insertDocumentsIntoCollection(documentsToInsert: any[], collectionName: string, collectionInsertOptions?: CollectionInsertManyOptions): Promise<import("mongodb").InsertWriteOpResult<any>>;
~~~~~~~~~~~~~~~~~~~
node_modules/mongo-seeding/dist/database/database.d.ts:55:93 - error TS2694: Namespace '"node_modules/mongodb/mongodb"' has no exported member 'DeleteWriteOpResultObject'.
55 removeAllDocumentsIfCollectionExists(collectionName: string): Promise<import("mongodb").DeleteWriteOpResultObject | undefined>;
~~~~~~~~~~~~~~~~~~~~~~~~~
Do you plan to upgrade mongodb (type) dependencies in the foreseeable future?
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
compile errors with v4.4.x under typescript 3.9.x and node 14
Unable to build a package depending on mongodb 4.4.x using ts 3.9. Notice a huge number of errors in node_modules/mongodb/mongodb.ts34.d.ts ...
Read more >Nodejs Driver v4.4.1 doesn't handle errors correctly - MongoDB
When I run commands on a collection and the db is closed the error isn't returned in the callback but the function call...
Read more >Error Importing "mongodb" with typescript - Stack Overflow
I'm encountering the same issue, though using Mongoose, which depends on MongoDB's native Node driver. The solution I came to was downgrading ...
Read more >Latest version of @types/mongodb breaks tsc build #38865
I've just tested typescript@3.6.3 with @types/mongodb@3.3.6 and there are no type errors on my end. Steps I took: mkdir mongotest cd mongotest ......
Read more >mongodb | Yarn - Package Manager
The official MongoDB driver for Node.js. Upgrading to version 4? ... NODE-4691: interrupt in-flight operations on heartbeat failure (#3457 (e641bd4) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pkosiec D’oh, sorry, you’re right.
(1) Yes, we have the recent
"mongodb": "4.2.1"
as a dependency. (2) But I just noticed that we still had"@types/mongodb": "4.0.7"
(3) After dropping the@types/mongodb
, as expected, I’ll end up with:Guess, I’ll just keep the @types for now 😃
@qqilihq I’m glad to hear that! 🙂
Just out of curiosity: do you also use the new MongoDB Node.js driver v4 (which has brand-new built-in TS types) as dependency in your app, similarly as @aleneum? I guess not, and that would explain that you didn’t need to touch the
tsconfig.json
file 🤔