diff --git a/src/effect/schema/class/MutableClass.ts b/src/effect/schema/class/MutableClass.ts index c21aa1e..8d31f96 100644 --- a/src/effect/schema/class/MutableClass.ts +++ b/src/effect/schema/class/MutableClass.ts @@ -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(identifier: string) { return ( 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) + S.Class(identifier)(fieldsOr, annotations) as TMutableClass< + Self, + Fields, + Struct.Encoded, + Struct.Context, + Struct.Constructor, + {}, + {} + > } diff --git a/src/effect/schema/class/tests.ts b/src/effect/schema/class/tests.ts index 40fd657..0207522 100644 --- a/src/effect/schema/class/tests.ts +++ b/src/effect/schema/class/tests.ts @@ -1,5 +1,18 @@ import { Schema as S } from "@effect/schema" import { MutableClass } from "./MutableClass" +import { pipe } from "remeda" +import { Mutable } from "./Mutable" +import { MobXObservable } from "./MobXObservable" + + +const UserSuper = () => pipe( + MutableClass("User")({ + id: S.BigIntFromSelf, + role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")), + }), + + v => MobXObservable(v), +) class User extends MutableClass("User")({