Missing Typescript detail on Mongoose-specific options
for updateOne, updateMany, etc.
#14378
Closed
2 tasks done
Labels
discussion
If you have any thoughts or comments on this issue, please share them!
Prerequisites
Mongoose version
8.2.0
Node.js version
18.18.0
MongoDB server version
7.0
Typescript version (if applicable)
4.5.2
Description
In #14342 , the
MongooseQueryOptions
type was edited to include& { [other: string]: any }
in order to support arbitrary options. Arbitrary options are fine, but the specific implementation broke Typescript support for all of the official Mongoose option properties, in the sense that there's no more auto-completion or in-line JSDoc displayed when you start typing something like "runValidators".This is caused by the use of the
Omit
Typescript utility in the type foroptions
inupdateOne
,updateMany
, and a few others. Since nowOmit
is being called on a type that has[other: string]: any
in it, that particular weak "other" property essentially wipes out all the official properties (I think due to the underlying implementation ofExclude
).Steps to Reproduce
Here's a screenshot of my IDE with the bug and trying to auto-complete the "timestamps" options. You can see it only shows "maxTimeMS" instead.
Expected Behavior
Here's what I would expect my IDE to show me. You can see it includes auto-complete and helpful documentation for "timestamps" now.
The text was updated successfully, but these errors were encountered: