Prerequisites
Mongoose version
8.10.2
Node.js version
20.10.0
MongoDB server version
6.0.2
Typescript version (if applicable)
5.7.2
Description
I have a model Post that references the model User. The User model includes an embedded field, addresses, which is overridden by the type UserDocumentOverrides using Types.DocumentArray<AddressInstance>. For some reason, this override causes a typing error when performing a lean query on the Post model and passing the query result to a function that expects a parameter of type IPost[].
Steps to Reproduce
Reproduction link here.
P.S. If I locally comment out line 21 of the user.ts file, the error disappears. However, for some reason, on StackBlitz, the error remains.
Expected Behavior
As a workaround, I can manually infer the type during the query .lean<IPost[]>(). However, I don't expect this type of error and having to manually specify the typing.