Typescript: $assertPopulated does not preserve the correct type of the document #12234
Closed
2 tasks done
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
6.5.1
Node.js version
16.13.2
MongoDB server version
5.x
Description
The recently-added $assertPopulated helper currently does not preserve the "document" type of a document instance, and instead just turns it into the underlying interface type:
From what I can tell, changing the definition from this:
to this:
would fix the problem.
Steps to Reproduce
See code snippet
Expected Behavior
I would expect that when working with a document instance, $assertPopulated should preserve the document type so that it's possible to save it etc.
The text was updated successfully, but these errors were encountered: