Definitelytyped: @types/connect-mongo Please update the dependency on @types/mongodb to version ^3

Created on 27 Jul 2018  路  1Comment  路  Source: DefinitelyTyped/DefinitelyTyped

I'm having an error when using connect-mongo and mongodb typings in my project.

const database: mongodb.Db = client.db(config.dbName);
const storeOptions: connectMongo.NativeMongoOptions = {
  db: database,
};

app.use(session({
  ...
  store: new MongoStore(storeOptions),
}));

the storeOptions produces an error:

Type '{ db: Db; }' is not assignable to type 'NativeMongoOptions'.
Types of property 'db' are incompatible.
Type 'import("/node_modules/@types/mongodb/index").Db' is not assignable to type 'import("/node_modules/@types/connect-mongo/node_modul...'.
Property 'authenticate' is missing in type 'Db'.

As far as I understand, this is because I'm using @types/mongodb^3 and the latest @types/connect-mongo is using @types/mongodb^2.
@Syati

Most helpful comment

+1
And while we are at it, let's please also update @types/connect-mongo's mongoose to ^5.

>All comments

+1
And while we are at it, let's please also update @types/connect-mongo's mongoose to ^5.

Was this page helpful?
0 / 5 - 0 ratings