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

missing typescript overload for cursor.eachasync #13152

Closed
2 tasks done
krosenk729 opened this issue Mar 9, 2023 · 2 comments · Fixed by #13153 or #13162
Closed
2 tasks done

missing typescript overload for cursor.eachasync #13152

krosenk729 opened this issue Mar 9, 2023 · 2 comments · Fixed by #13153 or #13162
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@krosenk729
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.6.1

Node.js version

18+

MongoDB server version

6+

Typescript version (if applicable)

4.5.5

Description

The fn callback for eachAsync should allow for an index parameter; however, the typescript definitions only allow for a single DocType or DocType[] param.

The function is properly shown in the documentation to allow i as an index here https://mongoosejs.com/docs/api/querycursor.html#querycursor_QueryCursor-eachAsync but the typescript definitions below prevent use of the second arg

    eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }, callback: CallbackWithoutResult): void;
    eachAsync(fn: (doc: DocType) => any, options: EachAsyncOptions, callback: CallbackWithoutResult): void;
    eachAsync(fn: (doc: DocType[]) => any, options: EachAsyncOptions & { batchSize: number }): Promise<void>;
    eachAsync(fn: (doc: DocType) => any, options?: EachAsyncOptions): Promise<void>;

Steps to Reproduce

Use mongoose in a .ts file and try Thing.find({}).cursor().eachAsync(async (doc, i) => { }) ... this will cause a typescript error No overload matches this call.

Expected Behavior

No response

@IslandRhythms IslandRhythms added the typescript Types or Types-test related issue / Pull Request label Mar 10, 2023
@hasezoey hasezoey linked a pull request Mar 13, 2023 that will close this issue
@hasezoey hasezoey added this to the 7.0.2 milestone Mar 13, 2023
@hasezoey
Copy link
Collaborator

closing because #13153 as been merged and will be available in 7.0.2

@hasezoey
Copy link
Collaborator

hasezoey commented Mar 13, 2023

nvm, forgot this issue was for 6.x and not 7.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
4 participants