Mutable
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
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 { HasFields, MissingSelfGeneric } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
export type TMutableClass<
|
||||||
|
Self,
|
||||||
|
Fields extends Struct.Fields,
|
||||||
|
I, R, C,
|
||||||
|
Inherited,
|
||||||
|
Proto,
|
||||||
|
> = (
|
||||||
|
Constructor<
|
||||||
|
Omit<
|
||||||
|
InstanceType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
|
keyof Fields
|
||||||
|
> &
|
||||||
|
Mutable<Struct.Type<Fields>>,
|
||||||
|
|
||||||
|
ConstructorParameters<Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||||
|
> &
|
||||||
|
|
||||||
|
Omit<
|
||||||
|
StaticType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
|
"extend"
|
||||||
|
> & {
|
||||||
|
extend<Extended = never>(identifier: string): <newFields extends Struct.Fields>(
|
||||||
|
fields: newFields | HasFields<newFields>,
|
||||||
|
annotations?: Annotations.Schema<Extended>,
|
||||||
|
) => [Extended] extends [never]
|
||||||
|
? MissingSelfGeneric<"Base.extend">
|
||||||
|
: TMutableClass<
|
||||||
|
Extended,
|
||||||
|
Fields & newFields,
|
||||||
|
I & Struct.Encoded<newFields>,
|
||||||
|
R | Struct.Context<newFields>,
|
||||||
|
C & Struct.Constructor<newFields>,
|
||||||
|
Self,
|
||||||
|
Proto
|
||||||
|
>
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
export function Mutable<
|
||||||
|
This extends Class<Self, Fields, I, R, C, Inherited, Proto>,
|
||||||
|
|
||||||
|
Self,
|
||||||
|
Fields extends Struct.Fields,
|
||||||
|
I, R, C,
|
||||||
|
Inherited,
|
||||||
|
Proto,
|
||||||
|
>(
|
||||||
|
class_:
|
||||||
|
| This
|
||||||
|
| Class<Self, Fields, I, R, C, Inherited, Proto>
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user