26 lines
831 B
TypeScript
26 lines
831 B
TypeScript
import { Schema as S } from "@effect/schema"
|
|
import type { Annotations, Struct } from "@effect/schema/Schema"
|
|
import type { TMutableClass } from "./TMutableClass"
|
|
import type { HasFields, MissingSelfGeneric } from "./util"
|
|
|
|
|
|
export const MutableClass = <Self = never>(identifier: string) => (
|
|
<Fields extends Struct.Fields>(
|
|
fieldsOr: Fields | HasFields<Fields>,
|
|
annotations?: Annotations.Schema<Self>,
|
|
): (
|
|
[Self] extends [never]
|
|
? MissingSelfGeneric<"Class">
|
|
: TMutableClass<
|
|
Self,
|
|
Fields,
|
|
Struct.Encoded<Fields>,
|
|
Struct.Context<Fields>,
|
|
Struct.Constructor<Fields>,
|
|
{},
|
|
{}
|
|
>
|
|
) =>
|
|
S.Class<Self>(identifier)(fieldsOr, annotations)
|
|
)
|