MutableClass
This commit is contained in:
@@ -1,7 +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 { StaticType } from "../../../StaticType"
|
||||
import type { TMutableClass } from "./TMutableClass"
|
||||
import type { HasFields } from "./util"
|
||||
|
||||
|
||||
@@ -17,7 +17,26 @@ extends Omit<
|
||||
"extend"
|
||||
>
|
||||
{
|
||||
new(
|
||||
...args: ConstructorParameters<Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||
): Omit<
|
||||
InstanceType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||
keyof Fields
|
||||
> &
|
||||
Mutable<Struct.Type<Fields>>
|
||||
|
||||
extend<Extended>(identifier: string): <newFields extends Struct.Fields>(
|
||||
fields: newFields | HasFields<newFields>,
|
||||
annotations?: Annotations.Schema<Extended>,
|
||||
) => IMutableClass<
|
||||
Extended,
|
||||
Fields & newFields,
|
||||
I & Struct.Encoded<newFields>,
|
||||
R | Struct.Context<newFields>,
|
||||
C & Struct.Constructor<newFields>,
|
||||
Self,
|
||||
Proto
|
||||
>
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +45,7 @@ export function MutableClass<Self>(identifier: string) {
|
||||
fieldsOr: Fields | HasFields<Fields>,
|
||||
annotations?: Annotations.Schema<Self>,
|
||||
) =>
|
||||
S.Class<Self>(identifier)(fieldsOr, annotations) as TMutableClass<
|
||||
S.Class<Self>(identifier)(fieldsOr, annotations) as IMutableClass<
|
||||
Self,
|
||||
Fields,
|
||||
Struct.Encoded<Fields>,
|
||||
|
||||
@@ -2,5 +2,5 @@ export { Class } from "./Class"
|
||||
export { MobXObservable } from "./MobXObservable"
|
||||
export { Mutable } from "./Mutable"
|
||||
export { MutableClass } from "./MutableClass"
|
||||
export type { TMutableClass } from "./TMutableClass"
|
||||
export type { IMutableClass } from "./MutableClass"
|
||||
export { TaggedClass } from "./TaggedClass"
|
||||
|
||||
@@ -8,14 +8,14 @@ import { TaggedClass } from "./TaggedClass"
|
||||
|
||||
|
||||
const UserSuper = <Self>() => pipe(
|
||||
// Class<Self>("User")({
|
||||
// id: S.BigIntFromSelf,
|
||||
// role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
|
||||
// }),
|
||||
TaggedClass<Self>()("User", {
|
||||
MutableClass<Self>("User")({
|
||||
id: S.BigIntFromSelf,
|
||||
role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
|
||||
}),
|
||||
// TaggedClass<Self>()("User", {
|
||||
// id: S.BigIntFromSelf,
|
||||
// role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
|
||||
// }),
|
||||
|
||||
// Mutable,
|
||||
MobXObservable,
|
||||
|
||||
Reference in New Issue
Block a user