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

Update mongodb-dependent type parameters #11688

Merged

Conversation

sandersn
Copy link
Contributor

@sandersn sandersn commented Apr 19, 2022

mongodb.Collection and mongodb.ChangeStream now both require that their type arguments extend mongodb.Document. This requires adding this constraint in a few places.

Fixes #11687

mongodb.Collection and mongodb.ChangeStream now both require that their
type arguments `extend mongodb.Document`. This requires adding this
constraint in a few places.
types/index.d.ts Outdated Show resolved Hide resolved
@jokester
Copy link

This PR may also help my DefinitelyTyped/DefinitelyTyped#59700 (comment) to land. Thanks 👍

It's mongodb.Document instead of AnyObject now, to match CollectionBase.
@Uzlopak
Copy link
Collaborator

Uzlopak commented Apr 20, 2022

Changes make sense to me. Only question for me is, does it have some backwards breaking? Or is mongodb.Document really just an AnyObject equivalent?

@sandersn
Copy link
Contributor Author

sandersn commented Apr 20, 2022

Right now, mongodb has

interface Document {
  [key: string]: any
}

and mongoose has

interface AnyObject {
  [k: string]: any
}

So there's definitely no break right now. They're identical from the compiler's perspective. mongodb.Document might change in the future, but (1) I assume that's unlikely (2) it makes sense at a surface level that interfaces that extend mongodb types and functions that return mongodb types should use mongodb-based types instead of mongoose types.

On (2), I don't know mongodb or mongoose, I just maintain Definitely Typed, so it's a guess on my part.

Copy link
Collaborator

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Uzlopak Uzlopak merged commit ca73eaf into Automattic:master Apr 20, 2022
@sandersn sandersn deleted the update-mongodb-dependent-type-parameters branch April 20, 2022 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsconfig.json format is wrong, so strictNullChecks is ignored
3 participants