Code improvement
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-07 18:53:28 +01:00
parent 9071a4fc9e
commit 01a950ca95

View File

@@ -1,4 +1,4 @@
import { Call, Fn, Pipe, Tuples } from "hotscript"
import { Fn, Pipe, Tuples } from "hotscript"
import { AbstractClass, Class, Opaque } from "type-fest"
import { AbstractTag, RemoveAbstractFromImplClass, Trait, TraitApplierSuperTag } from "."
import { ExtendFn, SimplifyFn, StaticMembersFn } from "./util"
@@ -24,24 +24,22 @@ export class TraitExpression<
get extends(): (
AbstractClass<
Pipe<[
InstanceType<Superclass>,
...Call<Tuples.Map<Trait.OwnImplInstanceFn>, AllTraits>,
], [
ExtendFn,
SimplifyFn,
Pipe<AllTraits, [
Tuples.Map<Trait.OwnImplInstanceFn>, // Map all the traits to the instance of their implementation class
Tuples.Prepend<InstanceType<Superclass>>, // 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
]>,
ConstructorParameters<Superclass>
> &
Pipe<[
Superclass,
...Call<Tuples.Map<Trait.OwnImplClassFn>, AllTraits>,
], [
Tuples.Map<StaticMembersFn>,
ExtendFn,
SimplifyFn,
Pipe<AllTraits, [
Tuples.Map<Trait.OwnImplClassFn>, // Map all the traits to their implementation class
Tuples.Prepend<Superclass>, // Add the superclass at the top of the list
Tuples.Map<StaticMembersFn>, // 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
]>
) {
return this.allTraits.reduce(