Skip to content

Commit

Permalink
Merge pull request #14798 from Automattic/vkarpov15/gh-14787
Browse files Browse the repository at this point in the history
types(cursor): indicate that cursor.next() can return null
  • Loading branch information
vkarpov15 authored Aug 10, 2024
2 parents 5d6463b + 2b4b2f9 commit 4fa87e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/types/querycursor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion types/cursor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4fa87e9

Please sign in to comment.