@@ -51,9 +51,18 @@ declare module 'mongoose' {
5151 * @param {T } T A generic type to be checked.
5252 * @returns true if {@link T} is Record OR false if {@link T} is of any type.
5353 */
54- type IsItRecordAndNotAny < T > = IsTAny < T > extends true ? false : T extends Record < any , any > ? true : false ;
54+ type IsItRecordAndNotAny < T > = IfEquals < T , any , false , T extends Record < any , any > ? true : false > ;
5555
56- type IsTAny < T > = keyof any extends keyof T ? ( unknown extends T ? true : false ) : false ;
56+ /**
57+ * @summary Checks if two types are identical.
58+ * @param {T } T The first type to be compared with {@link U}.
59+ * @param {U } U The seconde type to be compared with {@link T}.
60+ * @param {Y } Y A type to be returned if {@link T} & {@link U} are identical.
61+ * @param {N } N A type to be returned if {@link T} & {@link U} are not identical.
62+ */
63+ type IfEquals < T , U , Y = true , N = false > =
64+ ( < G > ( ) => G extends T ? 1 : 0 ) extends
65+ ( < G > ( ) => G extends U ? 1 : 0 ) ? Y : N ;
5766
5867/**
5968 * @summary Required path base type.
@@ -130,8 +139,7 @@ type PathEnumOrString<T extends SchemaTypeOptions<string>['enum']> = T extends (
130139 * @returns Number, "Number" or "number" will be resolved to string type.
131140 */
132141type ResolvePathType < PathValueType , Options extends SchemaTypeOptions < PathValueType > = { } > =
133- IsTAny < PathValueType > extends true ? Schema . Types . Mixed :
134- PathValueType extends ( infer Item ) [ ] ? ResolvePathType < Item > [ ] :
142+ PathValueType extends ( infer Item ) [ ] ? IfEquals < Item , never , Schema . Types . Mixed , ResolvePathType < Item > > [ ] :
135143 PathValueType extends StringConstructor | 'string' | 'String' | typeof Schema . Types . String ? PathEnumOrString < Options [ 'enum' ] > :
136144 PathValueType extends NumberConstructor | 'number' | 'Number' | typeof Schema . Types . Number ? number :
137145 PathValueType extends DateConstructor | 'date' | 'Date' | typeof Schema . Types . Date ? Date :
0 commit comments