From 44e7a3f98c3770c4318fa5762bc81ac2b52e3c33 Mon Sep 17 00:00:00 2001 From: Daniil Borysov Date: Thu, 25 Jan 2024 22:26:32 +0100 Subject: [PATCH] Add a `IsClass` type check to the `StructSchema` type --- src/utils.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 92df9755..77ce9d74 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -251,6 +251,13 @@ export type IsRecord = T extends object ? T : never : never + +/** + * Check if a type is a class type. + */ + +export type IsClass = T extends { new (...args: any[]): any } ? T : never + /** * Check if a type is a tuple. */ @@ -374,7 +381,9 @@ export type StructSchema = [T] extends [string | undefined | null] ? null : Struct : T extends object - ? T extends IsRecord + ? T extends IsClass + ? null + : T extends IsRecord ? null : { [K in keyof T]: Describe } : null