Working trait expression implements

This commit is contained in:
Julien Valverdé
2024-01-31 03:22:23 +01:00
parent e493331ff3
commit ff3991ae45
7 changed files with 49 additions and 62 deletions

View File

@@ -1,7 +1,4 @@
import { Simplify } from "type-fest"
import { GetTraitAbstractMembers, GetTraitClass, GetTraitImplClass, GetTraitImplInstance, GetTraitInstance, Trait, TraitAbstractMembers, TraitImplInstance, expresses, trait } from "."
import { MergeInheritanceTree, TraitsAbstractMembers } from "./util"
import { Call, Fn, Tuples } from "hotscript"
import { Implements, TraitAbstractMembers, expresses, trait } from "."
const PrintsHelloOnNew = trait()(Super =>
@@ -41,28 +38,16 @@ const ActiveStatefulSubscription = trait<ActiveStatefulSubscriptionAbstractMembe
class ActiveStatefulSubscription extends Super {}
)
// type Test = Simplify<TraitImplInstance<ReturnType<typeof Identifiable<bigint>>>>
type Test1 = [
TraitAbstractMembers<typeof StatefulSubscription>,
TraitAbstractMembers<typeof ActiveStatefulSubscription>,
]
type Test2 = TraitsAbstractMembers<[
typeof StatefulSubscription,
typeof ActiveStatefulSubscription,
]>
type Test3 = Simplify<
Call<Tuples.Map<GetTraitClass>, [
typeof StatefulSubscription,
typeof ActiveStatefulSubscription,
]>
>
// type Test2 = Simplify<MergeInheritanceTree<Test1>>
const appliedIdentifiable = Identifiable<bigint>().apply({} as any)
const exp = expresses(
Identifiable<bigint>(),
// Identifiable<number>()
)
type Impl = Implements<typeof exp>
const exp = expresses(Identifiable<bigint>(), Identifiable<number>())
class User implements ReturnType<typeof exp.implements> {
class User implements Implements<typeof exp> {
id: bigint = -1n
}