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

types(cursor): indicate that cursor.next() can return null #14798

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
types(cursor): indicate that cursor.next() can return null
Fix #14787
vkarpov15 committed Aug 8, 2024
commit 2b4b2f965e57723eb28b58d629ebc9faa8ad7c10
2 changes: 2 additions & 0 deletions test/types/querycursor.test.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ Test.find().cursor().
}).
then(() => console.log('Done!'));

Test.find().cursor().next().then((doc) => expectType<ITest | null>(doc));

async function gh14374() {
// `Parent` represents the object as it is stored in MongoDB
interface Parent {
2 changes: 1 addition & 1 deletion types/cursor.d.ts
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ declare module 'mongoose' {
* Get the next document from this cursor. Will return `null` when there are
* no documents left.
*/
next(): Promise<DocType>;
next(): Promise<DocType | null>;

options: Options;
}