Skip to content

Commit f3095c8

Browse files
Correctly recurse in InferRawDocType
1 parent bb59d94 commit f3095c8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

types/inferrawdoctype.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare module 'mongoose' {
2222

2323
/**
2424
* @summary Obtains schema Path type.
25-
* @description Obtains Path type by separating path type from other options and calling {@link ResolvePathType}
25+
* @description Obtains Path type by separating path type from other options and calling {@link ResolveRawPathType}
2626
* @param {PathValueType} PathValueType Document definition path type.
2727
* @param {TypeKey} TypeKey A generic refers to document definition.
2828
*/
@@ -61,14 +61,14 @@ declare module 'mongoose' {
6161
// so we can directly obtain its path type.
6262
ObtainRawDocumentPathType<Item, TypeKey>[] :
6363
// If the type key isn't callable, then this is an array of objects, in which case
64-
// we need to call ObtainDocumentType to correctly infer its type.
65-
Array<ObtainDocumentType<Item, any, { typeKey: TypeKey }>> :
64+
// we need to call InferRawDocType to correctly infer its type.
65+
Array<InferRawDocType<Item>> :
6666
IsSchemaTypeFromBuiltinClass<Item> extends true ?
6767
ObtainRawDocumentPathType<Item, TypeKey>[] :
6868
IsItRecordAndNotAny<Item> extends true ?
6969
Item extends Record<string, never> ?
7070
ObtainRawDocumentPathType<Item, TypeKey>[] :
71-
Array<ObtainDocumentType<Item, any, { typeKey: TypeKey }>> :
71+
Array<InferRawDocType<Item>> :
7272
ObtainRawDocumentPathType<Item, TypeKey>[]
7373
>:
7474
PathValueType extends ReadonlyArray<infer Item> ?
@@ -77,13 +77,13 @@ declare module 'mongoose' {
7777
Item extends Record<TypeKey, any> ?
7878
Item[TypeKey] extends Function | String ?
7979
ObtainRawDocumentPathType<Item, TypeKey>[] :
80-
ObtainDocumentType<Item, any, { typeKey: TypeKey }>[]:
80+
InferRawDocType<Item>[]:
8181
IsSchemaTypeFromBuiltinClass<Item> extends true ?
8282
ObtainRawDocumentPathType<Item, TypeKey>[] :
8383
IsItRecordAndNotAny<Item> extends true ?
8484
Item extends Record<string, never> ?
8585
ObtainRawDocumentPathType<Item, TypeKey>[] :
86-
Array<ObtainDocumentType<Item, any, { typeKey: TypeKey }>> :
86+
Array<InferRawDocType<Item>>> :
8787
ObtainRawDocumentPathType<Item, TypeKey>[]
8888
>:
8989
PathValueType extends StringSchemaDefinition ? PathEnumOrString<Options['enum']> :
@@ -114,6 +114,6 @@ declare module 'mongoose' {
114114
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
115115
IfEquals<PathValueType, {}> extends true ? any:
116116
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
117-
PathValueType extends Record<string, any> ? ObtainDocumentType<PathValueType, any, { typeKey: TypeKey }> :
117+
PathValueType extends Record<string, any> ? InferRawDocType<PathValueType> :
118118
unknown;
119119
}

0 commit comments

Comments
 (0)