We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8.10.0
22.13.1
8.0.4
5.7.3
According to the docs (https://mongoosejs.com/docs/subdocs.html#subdocuments-versus-nested-paths), nested paths are something that are guaranteed to exist on the model.
But the type inference shows that nested paths are optional which isn't correct afaik.
export const ExampleSchema = new Schema({ field1: { type: String, required: true, }, field2: { subfield1: String, }, }, { timestamps: true }) export default mongoose.model('example', ExampleSchema)
const ExampleDoc = new ExampleModel()
field2
When using a nested path in a schema, I expect the type inference to show that nested path as something required and not optional.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Prerequisites
Mongoose version
8.10.0
Node.js version
22.13.1
MongoDB server version
8.0.4
Typescript version (if applicable)
5.7.3
Description
According to the docs (https://mongoosejs.com/docs/subdocs.html#subdocuments-versus-nested-paths), nested paths are something that are guaranteed to exist on the model.
But the type inference shows that nested paths are optional which isn't correct afaik.
Steps to Reproduce
field2
in our example shows up as optional when it's supposed to be guaranteed.Expected Behavior
When using a nested path in a schema, I expect the type inference to show that nested path as something required and not optional.
The text was updated successfully, but these errors were encountered: