0.1.21 #21
@@ -1,5 +1,5 @@
|
||||
import { Schema as S } from "@effect/schema"
|
||||
import { Simplify } from "effect/Types"
|
||||
import { Mutable, Simplify } from "effect/Types"
|
||||
import { Trait, TraitTuple } from "../Trait"
|
||||
import { TraitExpression } from "../TraitExpression"
|
||||
import { TraitExpressionBuilder } from "../TraitExpressionBuilder"
|
||||
@@ -92,6 +92,37 @@ export class EffectSchemaTraitExpressionBuilder<
|
||||
) {}
|
||||
|
||||
|
||||
mutable(): EffectSchemaTraitExpressionBuilder<
|
||||
Fields,
|
||||
Mutable<A>,
|
||||
I,
|
||||
R,
|
||||
C,
|
||||
Inherited,
|
||||
Proto,
|
||||
Static,
|
||||
|
||||
Traits
|
||||
> {
|
||||
return new EffectSchemaTraitExpressionBuilder(this.expressionSuperclass, this.expressionTraits)
|
||||
}
|
||||
|
||||
mutableEncoded(): EffectSchemaTraitExpressionBuilder<
|
||||
Fields,
|
||||
A,
|
||||
Mutable<I>,
|
||||
R,
|
||||
C,
|
||||
Inherited,
|
||||
Proto,
|
||||
Static,
|
||||
|
||||
Traits
|
||||
> {
|
||||
return new EffectSchemaTraitExpressionBuilder(this.expressionSuperclass, this.expressionTraits)
|
||||
}
|
||||
|
||||
|
||||
expresses<
|
||||
const T extends readonly Trait<
|
||||
TraitExpression<
|
||||
|
||||
@@ -8,6 +8,8 @@ const userExp = effectSchemaExpression
|
||||
id: S.BigIntFromSelf,
|
||||
role: S.Union(S.Literal("User"), S.Literal("Admin")),
|
||||
})
|
||||
.mutable()
|
||||
.mutableEncoded()
|
||||
.build()
|
||||
|
||||
@userExp.staticImplements
|
||||
@@ -16,6 +18,10 @@ class User extends userExp.extends<User>() implements Implements<typeof userExp>
|
||||
static aStaticMethodThatShouldBeInherited() {}
|
||||
}
|
||||
|
||||
const user = new User({ id: 0n, role: "User" })
|
||||
user.id = 0n
|
||||
type UserEncoded = S.Schema.Encoded<typeof User>
|
||||
|
||||
|
||||
const adminExp = effectSchemaExpression
|
||||
.extends(User, "User", {
|
||||
@@ -27,4 +33,5 @@ const adminExp = effectSchemaExpression
|
||||
class Admin extends adminExp.extends<Admin>() implements Implements<typeof adminExp> {
|
||||
}
|
||||
|
||||
new Admin({ id: 0n, role: "Admin" }).aMethodThatShouldBeInherited()
|
||||
const admin = new Admin({ id: 1n, role: "Admin" })
|
||||
// admin.id = 1n
|
||||
|
||||
Reference in New Issue
Block a user