0.1.21 #21
53
src/effect/EffectSchemaTraitExpression.ts
Normal file
53
src/effect/EffectSchemaTraitExpression.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Schema as S } from "@effect/schema"
|
||||
import { Simplify } from "type-fest"
|
||||
import { Trait, TraitTuple } from "../Trait"
|
||||
import { StaticImplements, TraitExpression } from "../TraitExpression"
|
||||
import { Extend } from "../util"
|
||||
|
||||
|
||||
export class EffectSchemaTraitExpression<
|
||||
Superclass extends S.Class<unknown, Fields, A, I, R, C, Inherited, Proto>,
|
||||
Fields extends S.Struct.Fields,
|
||||
A, I, R, C,
|
||||
Inherited extends object,
|
||||
Proto,
|
||||
|
||||
const Traits extends readonly Trait<any, any, any, any>[],
|
||||
> {
|
||||
constructor(
|
||||
readonly superclass: Superclass,
|
||||
readonly traits: Traits,
|
||||
) {}
|
||||
|
||||
|
||||
extends<Self>(): (
|
||||
S.Class<
|
||||
Self,
|
||||
Fields,
|
||||
A, I, R, C,
|
||||
Simplify<
|
||||
Extend<[
|
||||
Inherited,
|
||||
...TraitTuple.MapImplInstance<Traits>
|
||||
]>
|
||||
>,
|
||||
Proto
|
||||
> &
|
||||
|
||||
Simplify<
|
||||
Extend<TraitTuple.MapImplStaticMembers<Traits>>
|
||||
>
|
||||
) {
|
||||
return this.traits.reduce(
|
||||
(previous, trait) => trait.apply(previous),
|
||||
this.superclass,
|
||||
) as any
|
||||
}
|
||||
|
||||
|
||||
staticImplements(_target: StaticImplements<TraitExpression<Superclass, Traits>>, _context: any) {}
|
||||
|
||||
get staticImplementsStage2() {
|
||||
return (_target: StaticImplements<TraitExpression<Superclass, Traits>>) => {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user