extendAbstract
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Julien Valverdé
2024-02-14 21:57:48 +01:00
parent 1758649507
commit a065daec1e
2 changed files with 25 additions and 4 deletions

View File

@@ -57,6 +57,19 @@ export class TraitBuilder<
) )
} }
extendAbstract<
A extends Abstract
>(
abstract: (Super: AbstractClass<Abstract>) => AbstractClass<A, []>
) {
return new TraitBuilder(
this.traitSuperExpression,
{} as A,
this.traitStaticAbstract,
this.traitApply,
)
}
implement< implement<
ImplClassWithAbstract extends ( ImplClassWithAbstract extends (
Class<Abstract, []> & Class<Abstract, []> &

View File

@@ -28,14 +28,22 @@ const Identifiable = <ID>() => trait
.build() .build()
const StatefulSubscription = trait const StatefulSubscription = trait
.abstract<{ // .abstract<{
readonly isStatefulSubscription: true // readonly isStatefulSubscription: true
readonly status: ( // readonly status: (
// { _tag: "awaitingPayment" } |
// { _tag: "active", activeSince: Date, expiresAt?: Date } |
// { _tag: "expired", expiredSince: Date }
// )
// }>()
.extendAbstract(Super => class extends Super {
readonly isStatefulSubscription!: true
readonly status!: (
{ _tag: "awaitingPayment" } | { _tag: "awaitingPayment" } |
{ _tag: "active", activeSince: Date, expiresAt?: Date } | { _tag: "active", activeSince: Date, expiresAt?: Date } |
{ _tag: "expired", expiredSince: Date } { _tag: "expired", expiredSince: Date }
) )
}>() })
.build() .build()
type StatefulSubscriptionClass = Trait.Class<typeof StatefulSubscription> type StatefulSubscriptionClass = Trait.Class<typeof StatefulSubscription>