Static & MutableClass
This commit is contained in:
8
src/Static.ts
Normal file
8
src/Static.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { AbstractConstructor } from "type-fest"
|
||||
|
||||
|
||||
/**
|
||||
* Represents the static members of a class.
|
||||
* @template C - A class.
|
||||
*/
|
||||
export type Static<C extends AbstractConstructor<any>> = Omit<C, "prototype">
|
||||
@@ -1,8 +1,28 @@
|
||||
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 { Static } from "../../Static"
|
||||
import type { HasFields, MissingSelfGeneric } from "./util"
|
||||
|
||||
|
||||
type TMutableClass<
|
||||
Self,
|
||||
Fields extends Struct.Fields,
|
||||
I, R, C,
|
||||
Inherited extends object,
|
||||
Proto,
|
||||
> = (
|
||||
Constructor<
|
||||
Mutable<Struct.Type<Fields>> &
|
||||
Omit<Inherited, keyof Fields>
|
||||
& Proto,
|
||||
|
||||
ConstructorParameters<Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||
> &
|
||||
Static<Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||
)
|
||||
|
||||
export const MutableClass = <Self = never>(identifier: string) => (
|
||||
<Fields extends Struct.Fields>(
|
||||
fieldsOr: Fields | HasFields<Fields>,
|
||||
@@ -10,7 +30,7 @@ export const MutableClass = <Self = never>(identifier: string) => (
|
||||
): (
|
||||
[Self] extends [never]
|
||||
? MissingSelfGeneric<"Class">
|
||||
: Class<
|
||||
: TMutableClass<
|
||||
Self,
|
||||
Fields,
|
||||
Struct.Encoded<Fields>,
|
||||
|
||||
@@ -1 +1 @@
|
||||
export {}
|
||||
export type { Static } from "./Static"
|
||||
|
||||
Reference in New Issue
Block a user