Effect CommunityEC
Effect Community17mo ago
23 replies
Guido

Defining a Generic `Schema.Class` Type in TypeScript

what's the proper type definition for a generic
Schema.Class
?

I'm trying to do this:
type Collections = Record<CollectionPath, {
    collectionPath: CollectionPath;
    schema: typeof Schema.Class;
}>;

class SomeSchemaClass extends Schema.Class<SomeSchemaClass>("SomeSchemaClass")({
  ...
}) {}

export const Collections: Collections = {
    someSchemaClass: {collectionPath: 'someSchemaClass', schema: SomeSchemaClass}
};


but i'm getting this type error (see screenshot for readability)
Screenshot_2024-08-29_at_2.18.42_PM.png
Was this page helpful?