Open
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
7.4.4
Node.js version
16.19.1
MongoDB server version
5
Typescript version (if applicable)
4.8.3
Description
The InferSchemaType
utility converts subdocument arrays into DocumentArray
s. My understanding is that this utility should produce a plain type that has nothing to do with Mongoose, so it should infer simple arrays instead of DocumentArray
s. Is my expectation incorrect?
Possibly related: #12030 .
Steps to Reproduce
const mySchema = new Schema({
nodes: {
type: [
new Schema({
foo: String
})
],
required: true
}
});
type IMySchema = InferSchemaType<typeof mySchema>;
Type IMySchema
is:
type IMySchema = {
nodes: Types.DocumentArray<{
foo?: string | undefined;
}>;
}
Expected Behavior
I'd expect type IMySchema
to be:
type IMySchema = {
nodes: Array<{
foo?: string | undefined;
}>;
}