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

[fix] Add back Typescript help for true Mongoose-specific options for updateOne, updateMany, etc. #14379

Merged
merged 3 commits into from Feb 26, 2024

Conversation

sderrow
Copy link
Contributor

@sderrow sderrow commented Feb 26, 2024

Summary
Addresses #14378. MongooseQueryOptions type was recently edited to include & { [other: string]: any } in order to support arbitrary options. This implementation broke Typescript support for all of the official Mongoose option properties, in the sense that there's no more auto-completion when you start typing something like "runValidators", and there's no in-line JSDoc displayed.

This is caused by the use of the Omit Typescript utility in the type for options in updateOne, updateMany, and a few others. Resolution is to redo the implementation with a build-up approach instead of using Omit.

Examples
See example and screenshots in #14378

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.

I think I prefer this approach over #14382, but I also want to merge the ExcludeKeys helper because Omit<> is awful. I'll merge this one as the fix, but also merge #14382 with some changes.

@vkarpov15 vkarpov15 added this to the 8.2.1 milestone Feb 26, 2024
@vkarpov15 vkarpov15 merged commit 68de586 into Automattic:master Feb 26, 2024
3 checks passed
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