This commit is contained in:
28
src/tests.ts
28
src/tests.ts
@@ -1,4 +1,4 @@
|
||||
import { Implements, abstract, expression, trait } from "."
|
||||
import { Implements, Trait, abstract, expression, trait } from "."
|
||||
|
||||
|
||||
const PrintsHelloOnNew = trait(
|
||||
@@ -22,6 +22,7 @@ const Identifiable = <ID>() => trait(
|
||||
|
||||
const StatefulSubscription = trait(
|
||||
abstract<{
|
||||
readonly isStatefulSubscription: true
|
||||
readonly status: (
|
||||
{ _tag: "awaitingPayment" } |
|
||||
{ _tag: "active", activeSince: Date, expiresAt?: Date } |
|
||||
@@ -32,14 +33,23 @@ const StatefulSubscription = trait(
|
||||
Super => class StatefulSubscription extends Super {},
|
||||
)
|
||||
|
||||
// interface ActiveStatefulSubscriptionAbstractMembers extends TraitAbstractMembers<typeof StatefulSubscription> {
|
||||
// readonly status: { _tag: "active", activeSince: Date, expiresAt?: Date }
|
||||
// }
|
||||
const ActiveStatefulSubscription = expression
|
||||
.expresses(StatefulSubscription)
|
||||
.build()
|
||||
.subtrait(
|
||||
exp => {
|
||||
interface IActiveStatefulSubscription extends Implements<typeof exp> {
|
||||
readonly isActiveStatefulSubscription: true
|
||||
readonly status: { _tag: "active", activeSince: Date, expiresAt?: Date }
|
||||
}
|
||||
|
||||
// const ActiveStatefulSubscription = trait(
|
||||
// abstract<ActiveStatefulSubscriptionAbstractMembers>(),
|
||||
// Super => class ActiveStatefulSubscription extends Super {},
|
||||
// )
|
||||
return abstract<IActiveStatefulSubscription>()
|
||||
},
|
||||
|
||||
Super => class ActiveStatefulSubscription extends Super {},
|
||||
)
|
||||
|
||||
type T = Trait.OwnAbstract<typeof ActiveStatefulSubscription>
|
||||
|
||||
|
||||
class TestSuperclass {
|
||||
@@ -47,7 +57,6 @@ class TestSuperclass {
|
||||
// static test = 69
|
||||
}
|
||||
|
||||
|
||||
const exp = expression
|
||||
.extends(TestSuperclass)
|
||||
.expresses(
|
||||
@@ -71,6 +80,7 @@ type Abs = Implements<typeof exp>
|
||||
// )
|
||||
|
||||
class User extends exp.extends implements Implements<typeof exp> {
|
||||
readonly isStatefulSubscription: true = true
|
||||
declare status: { _tag: "awaitingPayment" } | { _tag: "active"; activeSince: Date; expiresAt?: Date | undefined } | { _tag: "expired"; expiredSince: Date }
|
||||
id: bigint = -1n
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user