Skip to content

Commit

Permalink
Add a IsClass type check to the StructSchema type
Browse files Browse the repository at this point in the history
  • Loading branch information
Danofu committed Jan 25, 2024
1 parent c88b111 commit 44e7a3f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ export type IsRecord<T> = T extends object
? T
: never
: never

/**
* Check if a type is a class type.
*/

export type IsClass<T> = T extends { new (...args: any[]): any } ? T : never

/**
* Check if a type is a tuple.
*/
Expand Down Expand Up @@ -374,7 +381,9 @@ export type StructSchema<T> = [T] extends [string | undefined | null]
? null
: Struct<E>
: T extends object
? T extends IsRecord<T>
? T extends IsClass<T>
? null
: T extends IsRecord<T>
? null
: { [K in keyof T]: Describe<T[K]> }
: null
Expand Down

0 comments on commit 44e7a3f

Please sign in to comment.