Files
thilalib/src/effect/schema/class/MutableClass.ts
Julien Valverdé f0a01a3d73 Mutable work
2024-06-11 02:53:32 +02:00

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)
)