This commit is contained in:
@@ -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, []> &
|
||||||
|
|||||||
16
src/tests.ts
16
src/tests.ts
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user