This commit is contained in:
@@ -1,32 +1,34 @@
|
|||||||
import { AbstractClass, Simplify } from "type-fest"
|
import { AbstractClass, Simplify } from "type-fest"
|
||||||
import { Trait, Traits } from "./Trait"
|
import { Trait } from "./Trait"
|
||||||
import { TraitExpression } from "./TraitExpression"
|
import { TraitExpression } from "./TraitExpression"
|
||||||
import { ExtendPlain, StaticMembers } from "./util"
|
import { ExtendPlain, StaticMembers } from "./util"
|
||||||
|
|
||||||
|
|
||||||
type ImplSuper<
|
type ImplSuper<This> = (
|
||||||
SuperExpression extends TraitExpression<
|
This extends TraitBuilder<
|
||||||
typeof TraitExpression.NullSuperclass,
|
any,
|
||||||
Trait<any, any, any, any>[]
|
infer Abstract,
|
||||||
>,
|
infer StaticAbstract,
|
||||||
Abstract extends object,
|
infer ImplClass
|
||||||
StaticAbstract extends object,
|
>
|
||||||
> = (
|
? (
|
||||||
AbstractClass<
|
AbstractClass<
|
||||||
|
Simplify<
|
||||||
ExtendPlain<[
|
ExtendPlain<[
|
||||||
...Traits.MapImplInstance<
|
|
||||||
TraitExpression.Traits<SuperExpression>
|
|
||||||
>,
|
|
||||||
Abstract,
|
Abstract,
|
||||||
|
InstanceType<ImplClass>,
|
||||||
|
]>
|
||||||
|
>
|
||||||
|
> &
|
||||||
|
Simplify<
|
||||||
|
ExtendPlain<[
|
||||||
|
StaticAbstract,
|
||||||
|
StaticMembers<ImplClass>,
|
||||||
]>
|
]>
|
||||||
> &
|
> &
|
||||||
ExtendPlain<[
|
|
||||||
...Traits.MapImplStaticMembers<
|
|
||||||
TraitExpression.Traits<SuperExpression>
|
|
||||||
>,
|
|
||||||
StaticAbstract,
|
|
||||||
]> &
|
|
||||||
{ readonly _tag: "@thilawyn/traitify-ts/Super" } // TODO: replace with unique symbol?
|
{ readonly _tag: "@thilawyn/traitify-ts/Super" } // TODO: replace with unique symbol?
|
||||||
|
)
|
||||||
|
: never
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -69,15 +71,9 @@ export class TraitBuilder<
|
|||||||
}
|
}
|
||||||
|
|
||||||
implement<
|
implement<
|
||||||
ImplClassWithAbstract extends ImplSuper< // TODO: use This instead?
|
ImplClassWithAbstract extends ImplSuper<typeof this>
|
||||||
SuperExpression,
|
|
||||||
Abstract,
|
|
||||||
StaticAbstract
|
|
||||||
>
|
|
||||||
>(
|
>(
|
||||||
apply: (
|
apply: (Super: ImplSuper<typeof this>) => ImplClassWithAbstract
|
||||||
Super: ImplSuper<SuperExpression, Abstract, StaticAbstract>
|
|
||||||
) => ImplClassWithAbstract
|
|
||||||
) {
|
) {
|
||||||
return new TraitBuilder(
|
return new TraitBuilder(
|
||||||
this.traitSuperExpression,
|
this.traitSuperExpression,
|
||||||
@@ -91,9 +87,7 @@ export class TraitBuilder<
|
|||||||
InstanceType<ImplClassWithAbstract>,
|
InstanceType<ImplClassWithAbstract>,
|
||||||
keyof Abstract
|
keyof Abstract
|
||||||
>
|
>
|
||||||
>,
|
>
|
||||||
|
|
||||||
ConstructorParameters<ImplClassWithAbstract>
|
|
||||||
> &
|
> &
|
||||||
Simplify<
|
Simplify<
|
||||||
Omit<
|
Omit<
|
||||||
|
|||||||
Reference in New Issue
Block a user