TypeScript returns an error if you run a query on a subclass field of a model #14842
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
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).
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.