This commit is contained in:
Julien Valverdé
2024-06-11 16:54:46 +02:00
parent 98a48a8982
commit fe5a863d9b
2 changed files with 23 additions and 14 deletions

View File

@@ -1,25 +1,21 @@
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"
import type { HasFields } from "./util"
export function MutableClass<Self = never>(identifier: string) {
return <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)
S.Class<Self>(identifier)(fieldsOr, annotations) as TMutableClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
>
}