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