Unexpected error executing a lean query and passing the result of the query to a function that accepts a variable of that interface type. #15275
Labels
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
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 modelUser
. TheUser
model includes an embedded field,addresses
, which is overridden by the typeUserDocumentOverrides
usingTypes.DocumentArray<AddressInstance>
. For some reason, this override causes a typing error when performing a lean query on thePost
model and passing the query result to a function that expects a parameter of typeIPost[]
.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.The text was updated successfully, but these errors were encountered: