import { Schema as S } from "@effect/schema" import type { Annotations, Class, Struct } from "@effect/schema/Schema" import type { Mutable } from "effect/Types" import type { Constructor } from "type-fest" import type { StaticType } from "../.." import type { HasFields, MissingSelfGeneric } from "./util" export type TMutableClass< Self, Fields extends Struct.Fields, I, R, C, Inherited, Proto, > = ( Constructor< Omit< InstanceType>, keyof Fields > & Mutable>, ConstructorParameters> > & Omit< StaticType>, "extend" > & { extend(identifier: string): ( fields: newFields | HasFields, annotations?: Annotations.Schema, ) => [Extended] extends [never] ? MissingSelfGeneric<"Base.extend"> : TMutableClass< Extended, Fields & newFields, I & Struct.Encoded, R | Struct.Context, C & Struct.Constructor, Self, Proto > } ) export const MutableClass = (identifier: string) => ( ( fieldsOr: Fields | HasFields, annotations?: Annotations.Schema, ): ( [Self] extends [never] ? MissingSelfGeneric<"Class"> : TMutableClass< Self, Fields, Struct.Encoded, Struct.Context, Struct.Constructor, {}, {} > ) => S.Class(identifier)(fieldsOr, annotations) )