Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.

Home Page:https://mongoosejs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS: compatibility with latest mongodb

jack-theripper opened this issue · comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.5.3

Node.js version

v16.15.1

MongoDB server version

5.x

Description

[ERROR] 23:19:46 ⨯ Unable to compile TypeScript:
agenda_test.ts(10,18): error TS2345: Argument of type 'import("/node_modules/mongodb/mongodb").Db' is not assignable to parameter of type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").Db'.
  Types of property 'createCollection' are incompatible.
    Type '{ <TSchema extends import("/node_modules/bson/bson").Document = import("/node_modules/bson/bson").Document>(name: string, options?: import("/node_modules/mongodb/mongodb").CreateCollectionOptions | undefined):...' is not assignable to type '{ <TSchema extends import("/node_modules/bson/bson").Document = import("/node_modules/bson/bson").Document>(name: string, options?: import("/node_modules/agenda/node_modules/mongodb/mongodb").CreateCollectionO...'.
      Types of parameters 'options' and 'options' are incompatible.
        Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").CreateCollectionOptions | undefined' is not assignable to type 'import("/node_modules/mongodb/mongodb").CreateCollectionOptions | undefined'.
          Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").CreateCollectionOptions' is not assignable to type 'import("/node_modules/mongodb/mongodb").CreateCollectionOptions'.
            Types of property 'session' are incompatible.
              Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").ClientSession | undefined' is not assignable to type 'import("/node_modules/mongodb/mongodb").ClientSession | undefined'.
                Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").ClientSession' is not assignable to type 'import("/node_modules/mongodb/mongodb").ClientSession'.
                  Types of property 'clientOptions' are incompatible.
                    Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").MongoOptions | undefined' is not assignable to type 'import("/node_modules/mongodb/mongodb").MongoOptions | undefined'.
                      Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").MongoOptions' is not assignable to type 'import("/node_modules/mongodb/mongodb").MongoOptions'.
                        Types of property 'autoEncrypter' are incompatible.
                          Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").AutoEncrypter | undefined' is not assignable to type 'import("/node_modules/mongodb/mongodb").AutoEncrypter | undefined'.
                            Type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").AutoEncrypter' is not assignable to type 'import("/node_modules/mongodb/mongodb").AutoEncrypter'.
                              Types of parameters 'client' and 'client' are incompatible.
                                Type 'import("/node_modules/mongodb/mongodb").MongoClient' is not assignable to type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").MongoClient'.
                                  The types of 'options.autoEncrypter' are incompatible between these types.
                                    Type 'import("/node_modules/mongodb/mongodb").AutoEncrypter | undefined' is not assignable to type 'import("/node_modules/agenda/node_modules/mongodb/mongodb").AutoEncrypter | undefined'.

yarn list:

<....>
├─ agenda@4.3.0
│  ├─ cron-parser@^3.0.0
│  ├─ date.js@~0.3.3
│  ├─ debug@~4.3.0
│  ├─ human-interval@~2.0.0
│  ├─ moment-timezone@~0.5.27
│  ├─ mongodb@^4.1.0
│  └─ mongodb@4.9.0
│     ├─ bson@^4.7.0
│     ├─ denque@^2.1.0
│     ├─ mongodb-connection-string-url@^2.5.3
│     ├─ saslprep@^1.0.3
│     └─ socks@^2.7.0
<.....>
├─ mongodb@4.8.1
│  ├─ bson@^4.6.5
│  ├─ denque@^2.0.1
│  ├─ mongodb-connection-string-url@^2.5.2
│  ├─ saslprep@^1.0.3
│  └─ socks@^2.6.2
├─ mongoose@6.5.3
│  ├─ bson@^4.6.5
│  ├─ kareem@2.4.1
│  ├─ mongodb@4.8.1

Steps to Reproduce

yarn add agenda mongoose
import Agenda from 'agenda'
import { connect } from 'mongoose'

const agenda = new Agenda()
connect(dsn).then((mongoose) => agenda.mongo(mongoose.connections[0].db))

Expected Behavior

No response

#9939

I could compile just fine but did get an error when running the JavaScript

var agenda = new agenda_1["default"]();
             ^

TypeError: agenda_1.default is not a constructor
    at Object.<anonymous> (C:\Users\Drumm\Desktop\Work\debugging\Typescript\12353.js:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

import Agenda from 'agenda'
import { connect } from 'mongoose'

const agenda = new Agenda()
connect('mongodb://localhost:27017').then((mongoose) => agenda.mongo(mongoose.connections[0].db))

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

This issue was closed because it has been inactive for 19 days since being marked as stale.