0.1.0 #1
8
src/abstract.ts
Normal file
8
src/abstract.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Opaque } from "type-fest"
|
||||||
|
|
||||||
|
|
||||||
|
export type AbstractTag = "@thilawyn/traitify-ts/Abstract"
|
||||||
|
|
||||||
|
export function abstract<Abstract extends object = {}>() {
|
||||||
|
return {} as Opaque<Abstract, AbstractTag>
|
||||||
|
}
|
||||||
@@ -1,9 +1,19 @@
|
|||||||
import { Call, Pipe, Tuples } from "hotscript"
|
import { Call, Pipe, Tuples } from "hotscript"
|
||||||
import { AbstractClass, Opaque } from "type-fest"
|
import { AbstractClass, Class, Opaque } from "type-fest"
|
||||||
import { Trait, TraitAbstractMembersFn, TraitApplierSuperTag, TraitImplClassFn, TraitImplInstanceFn } from "."
|
import { AbstractTag, Trait, TraitAbstractMembersFn, TraitApplierSuperTag, TraitImplClassFn, TraitImplInstanceFn } from "."
|
||||||
import { ExtendFn, ExtendableFn, SimplifyFn, StaticMembersFn } from "./util"
|
import { ExtendFn, ExtendableFn, SimplifyFn, StaticMembersFn } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
type SubtraitApplier<
|
||||||
|
Traits extends Trait<any, any>[],
|
||||||
|
Abstract extends object,
|
||||||
|
ImplWithAbstract extends Class<Abstract, []>,
|
||||||
|
> = (
|
||||||
|
(Super: Opaque<AbstractClass<Abstract>, TraitApplierSuperTag>) => (
|
||||||
|
Opaque<ImplWithAbstract, TraitApplierSuperTag>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
class TraitExpression<
|
class TraitExpression<
|
||||||
Super extends AbstractClass<any>,
|
Super extends AbstractClass<any>,
|
||||||
Traits extends Trait<any, any>[],
|
Traits extends Trait<any, any>[],
|
||||||
@@ -40,6 +50,22 @@ class TraitExpression<
|
|||||||
this.superclass as Opaque<Super, TraitApplierSuperTag>,
|
this.superclass as Opaque<Super, TraitApplierSuperTag>,
|
||||||
) as any
|
) as any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subtrait<
|
||||||
|
SubtraitAbstract extends object,
|
||||||
|
SubtraitImpl extends Class<any>,
|
||||||
|
>(
|
||||||
|
abstract: (
|
||||||
|
abstract: Pipe<Traits, [
|
||||||
|
Tuples.Map<TraitAbstractMembersFn>,
|
||||||
|
SimplifyFn,
|
||||||
|
]>
|
||||||
|
) => Opaque<SubtraitAbstract, AbstractTag>,
|
||||||
|
|
||||||
|
// impl: ()
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Implements<Exp extends TraitExpression<any, any>> = (
|
export type Implements<Exp extends TraitExpression<any, any>> = (
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
export * from "./abstract"
|
||||||
export * from "./expresses"
|
export * from "./expresses"
|
||||||
export * from "./trait"
|
export * from "./trait"
|
||||||
|
|||||||
Reference in New Issue
Block a user