0.1.21 #21
@@ -1,5 +1,6 @@
|
||||
import { Schema as S } from "@effect/schema"
|
||||
import * as Types from "effect/Types"
|
||||
import { Simplify } from "type-fest"
|
||||
import { Trait, TraitTuple } from "../Trait"
|
||||
import { TraitExpression } from "../TraitExpression"
|
||||
import { TraitExpressionBuilder } from "../TraitExpressionBuilder"
|
||||
@@ -40,7 +41,7 @@ export class EffectSchemaInitialTraitExpressionBuilder {
|
||||
}
|
||||
|
||||
extends<
|
||||
Super extends S.Class<Self, Fields, I, R, C, Inherited, Proto>,
|
||||
Super extends StaticMembers<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||
Self,
|
||||
Fields extends S.Struct.Fields,
|
||||
I, R, C,
|
||||
@@ -49,14 +50,28 @@ export class EffectSchemaInitialTraitExpressionBuilder {
|
||||
|
||||
NewFields extends S.Struct.Fields,
|
||||
>(
|
||||
superclass: Super | S.Class<Self, Fields, I, R, C, Inherited, Proto>,
|
||||
superclass: Super | StaticMembers<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||
identifier: string,
|
||||
fields: NewFields,
|
||||
annotations?: S.Annotations.Schema<unknown>,
|
||||
) {
|
||||
return new EffectSchemaTraitExpressionBuilder(
|
||||
superclass.extend<unknown>(identifier)(fields, annotations),
|
||||
{} as Omit<StaticMembers<Super>, keyof S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||
superclass.extend<unknown>(identifier)(fields, annotations) as S.Class<
|
||||
unknown,
|
||||
Fields & NewFields,
|
||||
I & S.Struct.Encoded<NewFields>,
|
||||
R | S.Struct.Context<NewFields>,
|
||||
C & S.Struct.Constructor<NewFields>,
|
||||
Self,
|
||||
Proto
|
||||
>,
|
||||
|
||||
{} as Simplify<
|
||||
Omit<Super,
|
||||
"prototype" | keyof S.Class<Self, Fields, I, R, C, Inherited, Proto>
|
||||
>
|
||||
>,
|
||||
|
||||
[],
|
||||
)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type Extr<T> =
|
||||
: never
|
||||
|
||||
type InspectSchemaClass<T> = T extends S.Class<infer Self, infer Fields, infer I, infer R, infer C, infer Inherited, infer Proto>
|
||||
? C
|
||||
? Inherited
|
||||
: never
|
||||
|
||||
|
||||
@@ -38,14 +38,11 @@ const userExp = effectSchemaExpression
|
||||
.build()
|
||||
|
||||
@userExp.staticImplements
|
||||
class User extends userExp.extends<User>() implements Implements<typeof userExp> {
|
||||
export class User extends userExp.extends<User>() implements Implements<typeof userExp> {
|
||||
aMethodThatShouldBeInherited() {}
|
||||
static aStaticMethodThatShouldBeInherited() {}
|
||||
}
|
||||
|
||||
type T1 = InspectSchemaClass<typeof userExp.superclass>
|
||||
type T2 = InstanceType<typeof userExp.superclass>
|
||||
|
||||
const user = new User({ id: 0n, role: "User" })
|
||||
// user.id = 0n
|
||||
|
||||
@@ -57,8 +54,10 @@ const adminExp = effectSchemaExpression
|
||||
// .immutable()
|
||||
.build()
|
||||
|
||||
type T = InspectSchemaClass<typeof adminExp.superclass>
|
||||
|
||||
@adminExp.staticImplements
|
||||
class Admin extends adminExp.extends<Admin>() implements Implements<typeof adminExp> {
|
||||
export class Admin extends adminExp.extends<Admin>() implements Implements<typeof adminExp> {
|
||||
}
|
||||
|
||||
const admin = new Admin({ id: 1n, role: "Admin" })
|
||||
|
||||
Reference in New Issue
Block a user