TypeScript returns an error if you run a query on a subclass field of a model #14842
Closed
2 tasks done
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
8.6.0
Node.js version
20.10.0
MongoDB server version
6.0.2
Typescript version (if applicable)
5.5.4
Description
First of all, I find the new feature introduced by the minor release 8.6.0 very useful, which checks if fields exist in the main interface of the model when running queries! It’s a great idea!
However, I encountered a problem with models and subclasses: before 8.6.0, it was possible to run a query on a subclass field from the main model, but now TypeScript reports an error (solved old issue).
interfaces:
query:
Steps to Reproduce
Reproduction link: https://stackblitz.com/edit/vitejs-vite-jkwelc?file=src%2Findex.ts
Expected Behavior
Although the main interface does not include the fields of the subclasses, you should still be able to run a query from the main model, as it worked prior to version 8.6.0.
The text was updated successfully, but these errors were encountered: