This commit is contained in:
@@ -14,8 +14,8 @@ import { ExtendFn, SimplifyFn, StaticMembersFn } from "./util"
|
||||
|
||||
export class TraitExpression<
|
||||
Superclass extends AbstractClass<{}>,
|
||||
const OwnTraits extends Trait<any, any, any>[],
|
||||
const AllTraits extends Trait<any, any, any>[],
|
||||
const OwnTraits extends Trait<any, any, any, any>[],
|
||||
const AllTraits extends Trait<any, any, any, any>[],
|
||||
> {
|
||||
constructor(
|
||||
readonly superclass: Superclass,
|
||||
@@ -52,17 +52,20 @@ export class TraitExpression<
|
||||
subtrait<
|
||||
This extends TraitExpression<typeof TraitExpression.NullSuperclass, any, any>,
|
||||
SubtraitAbstract extends Implements<This>,
|
||||
SubtraitStaticAbstract extends StaticImplements<This>,
|
||||
SubtraitImplClassWithAbstract extends Class<SubtraitAbstract, []> & { _tag: TraitApplierSuperTag },
|
||||
>(
|
||||
this: This,
|
||||
abstract: (expression: This) => Opaque<SubtraitAbstract, AbstractTag>,
|
||||
apply: (Super: AbstractClass<SubtraitAbstract> & { _tag: TraitApplierSuperTag }) => SubtraitImplClassWithAbstract,
|
||||
this: This,
|
||||
abstract: (expression: This) => Opaque<SubtraitAbstract, AbstractTag>,
|
||||
staticAbstract: (expression: This) => Opaque<SubtraitStaticAbstract, AbstractTag>,
|
||||
apply: (Super: AbstractClass<SubtraitAbstract> & { _tag: TraitApplierSuperTag }) => SubtraitImplClassWithAbstract,
|
||||
) {
|
||||
return new Trait(
|
||||
this,
|
||||
// {} as RemoveSupertraitsAbstractFromAbstract<SubtraitAbstract, Implements<typeof this>>,
|
||||
{} as SubtraitAbstract, // TODO: find a way to cleanly substract Implements<typeof this> from this.
|
||||
apply as any as (Super: AbstractClass<{}>) => RemoveAbstractFromImplClass<SubtraitImplClassWithAbstract, SubtraitAbstract>,
|
||||
{} as SubtraitAbstract, // TODO: find a way to cleanly substract Implements<typeof this> from this.
|
||||
{} as SubtraitStaticAbstract,
|
||||
apply as any as (Super: AbstractClass<{}>) => RemoveAbstractFromImplClass<SubtraitImplClassWithAbstract, SubtraitAbstract, SubtraitStaticAbstract>,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -111,3 +114,12 @@ export type Implements<Exp extends TraitExpression<any, any, any>> = (
|
||||
SimplifyFn,
|
||||
]>
|
||||
)
|
||||
|
||||
export type StaticImplements<Exp extends TraitExpression<any, any, any>> = (
|
||||
Pipe<Exp, [
|
||||
TraitExpression.AllTraitsFn,
|
||||
Tuples.Map<Trait.OwnStaticAbstractFn>,
|
||||
ExtendFn,
|
||||
SimplifyFn,
|
||||
]>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user