Working trait expression implements
This commit is contained in:
31
src/tests.ts
31
src/tests.ts
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user