diff --git a/src/effect/schema/class/Mutable.ts b/src/effect/schema/class/Mutable.ts index d041490..566a16f 100644 --- a/src/effect/schema/class/Mutable.ts +++ b/src/effect/schema/class/Mutable.ts @@ -1,48 +1,7 @@ -import { Schema as S } from "@effect/schema" -import type { Annotations, Class, Struct } from "@effect/schema/Schema" -import type { Mutable } from "effect/Types" +import type { Class, Struct } from "@effect/schema/Schema" import type { Constructor } from "type-fest" import type { StaticType } from "../../.." -import type { HasFields, MissingSelfGeneric } from "./util" - - -export type TMutableClass< - Self, - Fields extends Struct.Fields, - I, R, C, - Inherited, - Proto, -> = ( - Constructor< - Omit< - InstanceType>, - keyof Fields - > & - Mutable>, - - ConstructorParameters> - > & - - Omit< - StaticType>, - "extend" - > & { - extend(identifier: string): ( - fields: newFields | HasFields, - annotations?: Annotations.Schema, - ) => [Extended] extends [never] - ? MissingSelfGeneric<"Base.extend"> - : TMutableClass< - Extended, - Fields & newFields, - I & Struct.Encoded, - R | Struct.Context, - C & Struct.Constructor, - Self, - Proto - > - } -) +import type { TMutableClass } from "./TMutableClass" export function Mutable< @@ -58,5 +17,21 @@ export function Mutable< | This | Class ) { + return class_ as ( + Constructor< + Omit< + InstanceType, + keyof InstanceType> + > & + InstanceType>, + ConstructorParameters> + > & + + Omit< + StaticType, + keyof StaticType> + > & + StaticType> + ) } diff --git a/src/effect/schema/class/MutableClass.ts b/src/effect/schema/class/MutableClass.ts index 91af1ba..dfb3861 100644 --- a/src/effect/schema/class/MutableClass.ts +++ b/src/effect/schema/class/MutableClass.ts @@ -1,49 +1,9 @@ import { Schema as S } from "@effect/schema" -import type { Annotations, Class, Struct } from "@effect/schema/Schema" -import type { Mutable } from "effect/Types" -import type { Constructor } from "type-fest" -import type { StaticType } from "../../.." +import type { Annotations, Struct } from "@effect/schema/Schema" +import type { TMutableClass } from "./TMutableClass" import type { HasFields, MissingSelfGeneric } from "./util" -export type TMutableClass< - Self, - Fields extends Struct.Fields, - I, R, C, - Inherited, - Proto, -> = ( - Constructor< - Omit< - InstanceType>, - keyof Fields - > & - Mutable>, - - ConstructorParameters> - > & - - Omit< - StaticType>, - "extend" - > & { - extend(identifier: string): ( - fields: newFields | HasFields, - annotations?: Annotations.Schema, - ) => [Extended] extends [never] - ? MissingSelfGeneric<"Base.extend"> - : TMutableClass< - Extended, - Fields & newFields, - I & Struct.Encoded, - R | Struct.Context, - C & Struct.Constructor, - Self, - Proto - > - } -) - export const MutableClass = (identifier: string) => ( ( fieldsOr: Fields | HasFields, diff --git a/src/effect/schema/class/TMutableClass.ts b/src/effect/schema/class/TMutableClass.ts new file mode 100644 index 0000000..8b4a183 --- /dev/null +++ b/src/effect/schema/class/TMutableClass.ts @@ -0,0 +1,44 @@ +import type { Annotations, Class, Struct } from "@effect/schema/Schema" +import type { Mutable } from "effect/Types" +import type { Constructor } from "type-fest" +import type { StaticType } from "../../.." +import type { HasFields, MissingSelfGeneric } from "./util" + + +export type TMutableClass< + Self, + Fields extends Struct.Fields, + I, R, C, + Inherited, + Proto, +> = ( + Constructor< + Omit< + InstanceType>, + keyof Fields + > & + Mutable>, + + ConstructorParameters> + > & + + Omit< + StaticType>, + "extend" + > & { + extend(identifier: string): ( + fields: newFields | HasFields, + annotations?: Annotations.Schema, + ) => [Extended] extends [never] + ? MissingSelfGeneric<"Base.extend"> + : TMutableClass< + Extended, + Fields & newFields, + I & Struct.Encoded, + R | Struct.Context, + C & Struct.Constructor, + Self, + Proto + > + } +) diff --git a/src/effect/schema/class/index.ts b/src/effect/schema/class/index.ts index 391c95d..48c560e 100644 --- a/src/effect/schema/class/index.ts +++ b/src/effect/schema/class/index.ts @@ -1,3 +1,4 @@ export { MobXObservable } from "./MobXObservable" +export { Mutable } from "./Mutable" export { MutableClass } from "./MutableClass" -export type { TMutableClass } from "./MutableClass" +export type { TMutableClass } from "./TMutableClass"