This commit is contained in:
52
src/tests.ts
52
src/tests.ts
@@ -1,25 +1,7 @@
|
||||
import { Trait, TraitClass } from "./Trait"
|
||||
import { TraitClass } from "./Trait"
|
||||
import { trait } from "./TraitBuilder"
|
||||
import { Implements, ImplementsStatic, TraitExpression } from "./TraitExpression"
|
||||
import { Implements, ImplementsStatic } from "./TraitExpression"
|
||||
import { expression } from "./TraitExpressionBuilder"
|
||||
import { ExtendPlain } from "./util"
|
||||
|
||||
|
||||
type ExtendAbstractSuper<
|
||||
SuperExpression extends TraitExpression<
|
||||
typeof TraitExpression.NullSuperclass,
|
||||
Trait<any, any, any, any>[]
|
||||
>,
|
||||
Abstract extends object,
|
||||
> = (
|
||||
// ExtendPlain<[
|
||||
// ...Trait.OwnAbstract<
|
||||
// TraitExpression.Traits<SuperExpression>[number]
|
||||
// >,
|
||||
// Abstract,
|
||||
// ]>
|
||||
TraitExpression.Traits<SuperExpression>[number]
|
||||
)
|
||||
|
||||
|
||||
const PrintsHelloOnNew = trait
|
||||
@@ -53,7 +35,7 @@ const StatefulSubscription = trait
|
||||
// { _tag: "expired", expiredSince: Date }
|
||||
// )
|
||||
// }>()
|
||||
.extendAbstract(Super => class extends Super {
|
||||
.extendAbstract(Super => class StatefulSubscriptionAbstract extends Super {
|
||||
readonly isStatefulSubscription!: true
|
||||
readonly status!: (
|
||||
{ _tag: "awaitingPayment" } |
|
||||
@@ -66,7 +48,7 @@ const StatefulSubscription = trait
|
||||
type StatefulSubscriptionClass = TraitClass<typeof StatefulSubscription>
|
||||
|
||||
const ActiveStatefulSubscription = expression
|
||||
.expresses(PrintsHelloOnNew, StatefulSubscription)
|
||||
.expresses(StatefulSubscription)
|
||||
.build()
|
||||
.subtrait()
|
||||
.extendAbstract(Super => class extends Super {
|
||||
@@ -76,11 +58,6 @@ const ActiveStatefulSubscription = expression
|
||||
.build()
|
||||
|
||||
type ActiveStatefulSubscriptionClass = TraitClass<typeof ActiveStatefulSubscription>
|
||||
type Test = ExtendAbstractSuper<
|
||||
Trait.OwnSuperExpression<typeof ActiveStatefulSubscription>,
|
||||
Trait.OwnAbstract<typeof ActiveStatefulSubscription>
|
||||
>
|
||||
|
||||
|
||||
class TestSuperclass {
|
||||
// id: number = 69
|
||||
@@ -111,18 +88,13 @@ class User extends exp.extends implements Implements<typeof exp> {
|
||||
console.log(new User())
|
||||
|
||||
|
||||
// class Test1 {
|
||||
// prop1: string = "ouient"
|
||||
// prop2: bigint = 1n
|
||||
// }
|
||||
type MyTuple = [
|
||||
{ values: { gneugneu: string } },
|
||||
{ values: { ataoy: "issou" } },
|
||||
]
|
||||
|
||||
// class Test2 extends Test1 {
|
||||
// readonly prop1 = "juif"
|
||||
// prop3: number = 69
|
||||
// }
|
||||
type MapToValues<T extends { values: object }[]> = {
|
||||
[K in keyof T]: T[K]["values"]
|
||||
}
|
||||
|
||||
// type PureKeys<T, U> = {
|
||||
// [K in keyof T]: K extends keyof U ? T[K] extends U[K] ? never : K : K;
|
||||
// }[keyof T]
|
||||
|
||||
// type T = PureKeys<Test2, Test1>
|
||||
type T = MapToValues<MyTuple>
|
||||
|
||||
Reference in New Issue
Block a user