-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
.populate() clobbers the return type with { [x: string]: NativeDate; } #14825
Comments
@smbogan Does |
Yes.
|
@smbogan You can try the following
Alternatively, you can provide it like this:
Other than that
The reason of the issue is that you provide Does it help? |
Using |
@vkarpov15 Created an MR to not confuse users in case if they provide timestamp options like in case that was mentioned above |
fix: fixing schema type based on timestamps schema options value
Prerequisites
Mongoose version
8.5.3
Node.js version
22.5.1
MongoDB server version
5.0
Typescript version (if applicable)
4.9.5
Description
The Typescript type for
populate
's return value:includes
MergeType<{ [x: string]: NativeDate; } & ...
.This causes later code to assume every property is of type
NativeDate
.This was observed after upgrading from mongoose 6.12.0 to 8.5.3.
Steps to Reproduce
findOne
, followed bypopulate
with a type parameter.Expected Behavior
The types to be properly merged without
{ [x: string]: NativeDate; }
being included.The text was updated successfully, but these errors were encountered: