Checking if a Schema is a Class in TypeScript

Hello, is there a way to check with types if a schema is
Schema.Class
?
I want to create an IsSchemaClass type helper. I tried something like the example below, but it doesn't work.
I tried to look at the implementation of
Schema.Class
, but I couldn't figure out a way to do this.
class Person extends Schema.Class<Person>("Person")({
  id: Schema.optional(S.Number),
  name: Schema.NonEmptyString,
}) {}

type IsSchemaClass<T> = T extends Schema.Class<any, any, any, any, any, any, any> ? true : false

type Result = IsSchemaClass<Person> // Here Result is `false`


What I want to do is, if the given schema is
Schema.Class
infer its fields, so if the code above were working, I would do something like so:
type ExtractSchemaClassFields<T> = T extends Schema.Class<any, infer Fields, any, any, any, any, any> ? Fields : never
Was this page helpful?