@@ -23,10 +23,10 @@ declare module 'mongoose' {
2323 * @param {EnforcedDocType } EnforcedDocType A generic type enforced by user "provided before schema constructor".
2424 * @param {TypeKey } TypeKey A generic of literal string type."Refers to the property used for path type definition".
2525 */
26- type ObtainDocumentType < DocDefinition , EnforcedDocType = any , TypeKey extends TypeKeyBaseType = DefaultTypeKey > =
26+ type ObtainDocumentType < DocDefinition , EnforcedDocType = any , TSchemaOptions extends Record < any , any > = DefaultSchemaOptions > =
2727 IsItRecordAndNotAny < EnforcedDocType > extends true ? EnforcedDocType : {
28- [ K in keyof ( RequiredPaths < DocDefinition , TypeKey > &
29- OptionalPaths < DocDefinition , TypeKey > ) ] : ObtainDocumentPathType < DocDefinition [ K ] , TypeKey > ;
28+ [ K in keyof ( RequiredPaths < DocDefinition , TSchemaOptions [ 'typeKey' ] > &
29+ OptionalPaths < DocDefinition , TSchemaOptions [ 'typeKey' ] > ) ] : ObtainDocumentPathType < DocDefinition [ K ] , TSchemaOptions [ 'typeKey' ] > ;
3030 } ;
3131
3232 /**
@@ -45,21 +45,24 @@ declare module 'mongoose' {
4545 * @param {TSchema } TSchema A generic of schema type instance.
4646 * @param {alias } alias Targeted generic alias.
4747 */
48- type ObtainSchemaGeneric < TSchema , alias extends 'EnforcedDocType' | 'M' | 'TInstanceMethods' | 'TQueryHelpers' | 'TVirtuals' | 'TStaticMethods' | 'TPathTypeKey ' | 'DocType' > =
49- TSchema extends Schema < infer EnforcedDocType , infer M , infer TInstanceMethods , infer TQueryHelpers , infer TVirtuals , infer TStaticMethods , infer TPathTypeKey , infer DocType >
48+ type ObtainSchemaGeneric < TSchema , alias extends 'EnforcedDocType' | 'M' | 'TInstanceMethods' | 'TQueryHelpers' | 'TVirtuals' | 'TStaticMethods' | 'TSchemaOptions ' | 'DocType' > =
49+ TSchema extends Schema < infer EnforcedDocType , infer M , infer TInstanceMethods , infer TQueryHelpers , infer TVirtuals , infer TStaticMethods , infer TSchemaOptions , infer DocType >
5050 ? {
5151 EnforcedDocType : EnforcedDocType ;
5252 M : M ;
5353 TInstanceMethods : TInstanceMethods ;
5454 TQueryHelpers : TQueryHelpers ;
5555 TVirtuals : TVirtuals ;
5656 TStaticMethods : TStaticMethods ;
57- TPathTypeKey : TPathTypeKey ;
57+ TSchemaOptions : TSchemaOptions ;
5858 DocType : DocType ;
5959 } [ alias ]
6060 : unknown ;
61+
62+ type ResolveSchemaOptions < T > = Omit < MergeType < DefaultSchemaOptions , T > , 'statics' | 'methods' | 'query' | 'virtuals' > ;
6163}
6264
65+
6366/**
6467 * @summary Checks if a document path is required or optional.
6568 * @param {P } P Document path.
@@ -168,5 +171,5 @@ type ResolvePathType<PathValueType, Options extends SchemaTypeOptions<PathValueT
168171 IfEquals < PathValueType , ObjectConstructor > extends true ? any :
169172 IfEquals < PathValueType , { } > extends true ? any :
170173 PathValueType extends typeof SchemaType ? PathValueType [ 'prototype' ] :
171- PathValueType extends Record < string , any > ? ObtainDocumentType < PathValueType , any , TypeKey > :
174+ PathValueType extends Record < string , any > ? ObtainDocumentType < PathValueType , any , { typeKey : TypeKey } > :
172175 unknown ;
0 commit comments