-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 typings breaking changes with v6.2.5 #11518
Comments
I was checking index.d.ts regarding blame, and I could not find a recent change regarding the typings of populate. Not saying, that your claim is invalid, but to avoid regressions it is good to know when the regression was introduced. |
In #11503 we already improve the typing of populate. I also mentioned a potential fix for this issue. |
Sorry for the trouble, fix will be in v6.2.6 👍 |
@vkarpov15 Before I was doing stuff like that: interface IModel extends Document {
propA: PopulatedDoc<IModelA, Types.ObjectId>;
propB: PopulatedDoc<IModelB, Types.ObjectId>;
createdAt: Date;
updatedAt: Date;
}
const doc = await Model.findById(myId)
.populate<{propA: Pick<IModelA, "name">}>("propA", "name")
.populate<{propB: Pick<IModelB, "name">}>("propB", "name")
.lean() And this was compatible with function accepting parameters like that: function (doc: LeanDocument<IModel & { propA: Pick<IModelA, "name"> }> | null) {
// ...
} Now (v6.2.6) I have errors like:
I am not sure if it is a regression or if I have to write it differently now!? |
Should be fixed now. If the bug still exists after you updated mongoose, then feel free to reopen an issue. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Typings with populate expect a
string
for the path parameter, before it was typed withany
.If the current behavior is a bug, please provide the steps to reproduce.
Until version 6.2.5, I used populate with an array when populating multiple fields, like
.populate(['field1', 'field2'])
Typescript version: 4.5.5
What is the expected behavior?
I don't know if this is wanted, but upgrading to v6.2.5 is a breaking change.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJS version: 14
The text was updated successfully, but these errors were encountered: