diff --git a/src/TraitExpression.ts b/src/TraitExpression.ts index e789b05..1a1c4c9 100644 --- a/src/TraitExpression.ts +++ b/src/TraitExpression.ts @@ -1,8 +1,7 @@ -import { Fn, Pipe, Tuples } from "hotscript" import { AbstractClass, Class, Simplify } from "type-fest" import { Trait, TraitInstance, TraitStaticMembers, Traits } from "./Trait" import { TraitBuilder } from "./TraitBuilder" -import { ExtendFn, ExtendPlain, SimplifyFn, StaticMembers, StaticMembersFn } from "./util" +import { ExtendPlain, StaticMembers } from "./util" export class TraitExpression< @@ -16,23 +15,22 @@ export class TraitExpression< get extends(): ( AbstractClass< - Pipe, // Map all the traits to the instance of their implementation class - Tuples.Prepend>, // Add the instance of the superclass at the top of the list - ExtendFn, // Reduce to a single instance that extends all the instances in the list - SimplifyFn, // Make readable for IDEs - ]>, + Simplify< + ExtendPlain<[ + InstanceType, + ...Traits.MapImplInstance, + ]> + >, ConstructorParameters > & - Pipe, // Map all the traits to their implementation class - Tuples.Prepend, // Add the superclass at the top of the list - Tuples.Map, // Map all the classes to an object containing their static members - ExtendFn, // Reduce to a single object that extends all the objects in the list - SimplifyFn, // Make readable for IDEs - ]> + Simplify< + ExtendPlain<[ + StaticMembers, + ...Traits.MapImplStaticMembers, + ]> + > ) { return this.traits.reduce( (previous, trait) => trait.apply(previous), @@ -85,18 +83,12 @@ export namespace TraitExpression { ? Superclass : never ) - export interface SuperclassFn extends Fn { - return: TraitExpression.Superclass - } export type Traits = ( T extends TraitExpression ? Traits : never ) - export interface TraitsFn extends Fn { - return: TraitExpression.Traits - } }