diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts index f99251a641b..6843e12cfaa 100644 --- a/test/types/schema.test.ts +++ b/test/types/schema.test.ts @@ -540,7 +540,7 @@ export type AutoTypedSchemaType = { favoritDrink?: 'Tea' | 'Coffee', favoritColorMode: 'dark' | 'light' friendID?: Types.ObjectId; - nestedArray: Array<{ + nestedArray: Types.DocumentArray<{ date: Date; messages?: number; }> @@ -661,7 +661,12 @@ function gh12030() { ] }); - // expectType<{ users: Types.DocumentArray<{ userName?: string, credit: number }> }>({} as InferSchemaType); + expectType<{ + users: Types.DocumentArray<{ + credit: number; + username?: string; + }>; + }>({} as InferSchemaType); const Schema4 = new Schema({ @@ -674,7 +679,7 @@ function gh12030() { data: { type: { role: Object }, default: {} } }); - expectType<{ data: { role?: string } }>({} as InferSchemaType); + expectType<{ data: { role?: any } }>({} as InferSchemaType); const Schema6 = new Schema({ track: { diff --git a/types/inferschematype.d.ts b/types/inferschematype.d.ts index 1cf0cf91bae..b32a97b9ef7 100644 --- a/types/inferschematype.d.ts +++ b/types/inferschematype.d.ts @@ -171,7 +171,7 @@ type PathEnumOrString['enum']> = T extends ( */ type ResolvePathType = {}, TypeKey extends TypeKeyBaseType = DefaultTypeKey> = PathValueType extends Schema ? InferSchemaType : - PathValueType extends (infer Item)[] ? IfEquals>[] : + PathValueType extends (infer Item)[] ? IfEquals> : ResolvePathType[]> : PathValueType extends StringSchemaDefinition ? PathEnumOrString : PathValueType extends NumberSchemaDefinition ? number : PathValueType extends DateSchemaDefinition ? Date :