-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-3115): Add generic parameterization #2767
Conversation
271ce21
to
16f0df0
Compare
98135ef
to
b7fce6b
Compare
b7fce6b
to
1de5be6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
MongoClient, Db, Collection, and Cursors can now accept generic parameters to type check the usage of the various API methods on each class. Using generics is kept optional.
…emove abstract cursor generic constraint
1de5be6
to
2136bdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things left to clean up - almost there!
src/change_stream.ts
Outdated
const stream = changeStream[kCursorStream] || cursor.stream(); | ||
changeStream[kCursorStream] = stream; | ||
stream.on('data', change => processNewChange(changeStream, change)); | ||
stream.on('error', error => processError(changeStream, error)); | ||
} | ||
|
||
function endStream(changeStream: ChangeStream): void { | ||
function endStream(changeStream: ChangeStream<any>): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this one also be typed or is it an intentional omission?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Add Generics to Typescript Code
Building upon the splendiferous efforts in the community typings, I've brought inhouse the functionality to create collections across a typescript type. Please see the comments I'll post in short order for implementation details.
It's worth calling out: This does not enable runtime type checking, or BSON to class mapping.
NODE-3115