DocumentArrays defined in TMethodsAndOverrides do not correctly override Arrays. #13040
Closed
2 tasks done
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
6.9.1
Node.js version
12.22.10
MongoDB server version
5
Typescript version (if applicable)
4.9.5
Description
I was following this example from the official docs: https://mongoosejs.com/docs/typescript/subdocuments.html#subdocument-arrays.
Unfortunately, there is problem in the provided example:
Seems that Array methods, such as
forEach
,find
, etc. are not correctly overridden by DocumentArray.Steps to Reproduce
Here's a full custom example:
If
interface User
did not haveproducts: Product[]
defined, the error would go away. This is not a great solution however.Expected Behavior
Using Array prototype methods such as forEach, find and others on a DocumentArray override should correctly infer array entry types to be Subdocuments, not POJOs.
The text was updated successfully, but these errors were encountered: