Skip to content

Commit 445a76d

Browse files
authored
Merge pull request #15038 from Automattic/vkarpov15/gh-14976
types(cursor): correct `asyncIterator` and `asyncDispose` for TypeScript with lib: 'esnext'
2 parents 93dad98 + 48407d9 commit 445a76d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

types/cursor.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ declare module 'mongoose' {
1111
signal?: AbortSignal;
1212
}
1313

14-
class Cursor<DocType = any, Options = never> extends stream.Readable {
15-
[Symbol.asyncIterator](): AsyncIterableIterator<DocType>;
14+
class Cursor<DocType = any, Options = never, NextResultType = DocType | null> extends stream.Readable {
15+
[Symbol.asyncIterator](): Cursor<IteratorResult<DocType>, Options, IteratorResult<DocType>>;
16+
17+
[Symbol.asyncDispose](): Promise<void>;
1618

1719
/**
1820
* Adds a [cursor flag](https://mongodb.github.io/node-mongodb-native/4.9/classes/FindCursor.html#addCursorFlag).
@@ -58,7 +60,7 @@ declare module 'mongoose' {
5860
* Get the next document from this cursor. Will return `null` when there are
5961
* no documents left.
6062
*/
61-
next(): Promise<DocType | null>;
63+
next(): Promise<NextResultType>;
6264

6365
options: Options;
6466
}

0 commit comments

Comments
 (0)