MutableTaggedClass work

This commit is contained in:
Julien Valverdé
2024-06-14 02:47:21 +02:00
parent 5f717cbdc2
commit dc5c56ddef

View File

@@ -1,21 +1,25 @@
import { Schema as S } from "@effect/schema"
import type { Annotations, Struct } from "@effect/schema/Schema"
import type { TMutableClass } from "./TMutableClass"
import type { Annotations, PropertySignature, Struct } from "@effect/schema/Schema"
import type { HasFields } from "./util"
export function MutableClass<Self>(identifier: string) {
return <Fields extends Struct.Fields>(
export function MutableTaggedClass<Self>(identifier?: string) {
return <
Tag extends string,
Fields extends Struct.Fields,
>(
tag: Tag,
fieldsOr: Fields | HasFields<Fields>,
annotations?: Annotations.Schema<Self>,
) =>
S.Class<Self>(identifier)(fieldsOr, annotations) as TMutableClass<
// S.TaggedClass<Self>(identifier)(tag, fieldsOr, annotations) as S.TaggedClass<
// Self,
// Tag,
// { readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
// >
S.TaggedClass<Self>(identifier)(tag, fieldsOr, annotations) as S.TaggedClass<
Self,
Fields,
Struct.Encoded<Fields>,
Struct.Context<Fields>,
Struct.Constructor<Fields>,
{},
{}
Tag,
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
>
}