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

refactor(index.d.ts): make callbacks use the new Callback and CallbackWithoutResult types #10550

Merged
merged 3 commits into from
Aug 11, 2021

Conversation

thiagokisaki
Copy link
Contributor

No description provided.

index.d.ts Outdated
@@ -2616,8 +2616,8 @@ declare module 'mongoose' {
*/
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number }): Promise<void>;
eachAsync(fn: (doc: DocType[]) => any, options: { parallel?: number, batchSize: number }): Promise<void>;
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number, batchSize?: number }, cb?: (err: CallbackError) => void): void;
eachAsync(fn: (doc: DocType[]) => any, options: { parallel?: number, batchSize: number }, cb?: (err: CallbackError) => void): void;
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number, batchSize?: number }, cb?: Callback): void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it might be a problem: this change makes the eachAsync() callback take a param. Is this intentional or maybe we should have a CallbackNoResult type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. It might be a problem. Although Callback still allows you to pass a callback receiving only the error, it can mislead users that callback is called with two arguments. It's better to create a CallbackNoResult as you mentioned.

@thiagokisaki thiagokisaki changed the title refactor(index.d.ts): add Callback type to avoid code repetition refactor(index.d.ts): make callbacks use the new Callback and CallbackWithoutResult types Aug 9, 2021
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks 👍

@vkarpov15 vkarpov15 added this to the 5.13.7 milestone Aug 11, 2021
@vkarpov15 vkarpov15 merged commit 0b3083a into Automattic:master Aug 11, 2021
@thiagokisaki thiagokisaki deleted the patch-5 branch August 12, 2021 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants