This commit is contained in:
13
src/tests.ts
13
src/tests.ts
@@ -1,10 +1,11 @@
|
||||
import { Trait, trait } from "./Trait"
|
||||
import { Implements } from "./TraitExpression"
|
||||
import { Implements, StaticImplements } from "./TraitExpression"
|
||||
import { expression } from "./TraitExpressionBuilder"
|
||||
import { abstract } from "./abstract"
|
||||
|
||||
|
||||
const PrintsHelloOnNew = trait(
|
||||
abstract(),
|
||||
abstract(),
|
||||
Super => class PrintsHelloOnNew extends Super {
|
||||
static readonly isPrintsHelloOnNew = true
|
||||
@@ -19,6 +20,7 @@ type PrintsHelloOnNewClass = Trait.Class<typeof PrintsHelloOnNew>
|
||||
|
||||
const Identifiable = <ID>() => trait(
|
||||
abstract<{ readonly id: ID }>(),
|
||||
abstract(),
|
||||
Super => class Identifiable extends Super {
|
||||
equals(el: Identifiable) {
|
||||
return this.id === el.id
|
||||
@@ -35,6 +37,7 @@ const StatefulSubscription = trait(
|
||||
{ _tag: "expired", expiredSince: Date }
|
||||
)
|
||||
}>(),
|
||||
abstract(),
|
||||
|
||||
Super => class StatefulSubscription extends Super {},
|
||||
)
|
||||
@@ -53,6 +56,8 @@ const ActiveStatefulSubscription = expression
|
||||
return abstract<IActiveStatefulSubscription>()
|
||||
},
|
||||
|
||||
exp => abstract<StaticImplements<typeof exp>>(),
|
||||
|
||||
Super => class ActiveStatefulSubscription extends Super {},
|
||||
)
|
||||
|
||||
@@ -86,7 +91,9 @@ class User extends exp.extends implements Implements<typeof exp> {
|
||||
console.log(new User())
|
||||
|
||||
|
||||
declare function StaticImplements(target: { issou: string }, context: any): typeof target
|
||||
declare function StaticImplements(target: { issou: string }, context: any): void
|
||||
|
||||
@StaticImplements
|
||||
class Gneugneu {}
|
||||
class Gneugneu {
|
||||
// static issou: string = "juif"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user