Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The types of 'options.autoEncrypter' are incompatible #434

Closed
guyellis opened this issue Aug 25, 2021 · 13 comments
Closed

The types of 'options.autoEncrypter' are incompatible #434

guyellis opened this issue Aug 25, 2021 · 13 comments
Labels

Comments

@guyellis
Copy link
Contributor

  • I'm submitting a ...
    [ ] bug report
    [x] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

When upgrading the mongodb dependency from 4.1.0 to 4.1.1 this is the TypeScript error:

Type 'import(".../node_modules/mongodb/mongodb").MongoClient' is 
not assignable to type 
'import(".../node_modules/connect-mongo/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/connect-mongo/node_modules/mongodb/mongodb").AutoEncrypter |
      undefined'.

I think that the fix is as simple as upgrading the dependency in package.json:

"mongodb": "4.1.0"

@rfox12
Copy link
Contributor

rfox12 commented Aug 26, 2021

I'm not an expert on NPM libraries, but isn't it best to have mongodb specified as a peerDependency rather than a dependency pinned to a specific version? Wouldn't that prevent connect-mongo from breaking every time mongodb types are changed?

@guyellis
Copy link
Contributor Author

@rfox12 yes and no.

Yes - it would stop it breaking in this context and in that way.

No - what if connect-mongo relies on the schema? Say 4.1.1 removes a property but connect-mongo relies on that property being there. Now as a peerDependency it will still break.

@rfox12
Copy link
Contributor

rfox12 commented Aug 26, 2021

If mongodb is abiding by good semver citizenship (which I think they will), the promise with minor and patch releases is that they do not break the interface...

I've added a pull request.

@guyellis
Copy link
Contributor Author

If mongodb is abiding by good semver citizenship (which I think they will), the promise with minor and patch releases is that they do not break the interface...

My example wasn't very good - or deep enough.

Let's say that they removed an optional property from the type that should not have been there because it was not used. That might technically break the TypeScript schema but would not causing a functional breaking change.

@guyellis
Copy link
Contributor Author

I've added a pull request.

Thank you! 💯

@mingchuno
Copy link
Collaborator

link to #433
I think I would tried the peerDependency approach first to see if it work. @rfox12 @guyellis Any idea on the drawback on moving mongodb to peerDependency? Will it break current user?

@mingchuno
Copy link
Collaborator

4.6.0 released

@rfox12
Copy link
Contributor

rfox12 commented Sep 17, 2021

I don't think we're going to break anyone's usage. I upgraded just now and my update moved me to mongodb@4.1.2 and connect-mongo@4.6.0 with no issues! Thanks

@guyellis
Copy link
Contributor Author

Any idea on the drawback on moving mongodb to peerDependency? Will it break current user?

I think it works the way that you've done it with ^ optimistic.

@huineng
Copy link

huineng commented Sep 17, 2021

it works, i just had to delete node_modules and package-lock.json and reinstall. thanks

@guyellis
Copy link
Contributor Author

it works, i just had to delete node_modules and package-lock.json and reinstall. thanks

@huineng did you run into: TextEncoder is not defined that caused you to do that?

@huineng
Copy link

huineng commented Sep 17, 2021

no sorry, i got "cannot find mongo"

@rfox12
Copy link
Contributor

rfox12 commented Sep 18, 2021

@huineng You'll simply want to ensure mongodb is in your package.json dependencies.
npm install mongodb or
yarn install mongodb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants