Switched branding to string litteral
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
12
src/Trait.ts
12
src/Trait.ts
@@ -4,7 +4,7 @@ import { AbstractTag, TraitExpression, emptyTraitExpression } from "."
|
|||||||
import { ExtendFn, SimplifyFn, StaticMembers, StaticMembersFn } from "./util"
|
import { ExtendFn, SimplifyFn, StaticMembers, StaticMembersFn } from "./util"
|
||||||
|
|
||||||
|
|
||||||
export const isTraitApplierSuper = Symbol("isTraitApplierSuper")
|
export type TraitApplierSuperTag = "@thilawyn/traitify-ts/TraitApplierSuper"
|
||||||
|
|
||||||
|
|
||||||
export type AddAbstractToImplClass<
|
export type AddAbstractToImplClass<
|
||||||
@@ -19,14 +19,14 @@ export type AddAbstractToImplClass<
|
|||||||
)
|
)
|
||||||
|
|
||||||
export type RemoveAbstractFromImplClass<
|
export type RemoveAbstractFromImplClass<
|
||||||
ImplClassWithAbstract extends Class<Abstract, []> & { [isTraitApplierSuper]: true },
|
ImplClassWithAbstract extends Class<Abstract, []> & { _tag: TraitApplierSuperTag },
|
||||||
Abstract extends {},
|
Abstract extends {},
|
||||||
> = (
|
> = (
|
||||||
Class<
|
Class<
|
||||||
Omit<InstanceType<ImplClassWithAbstract>, keyof Abstract>,
|
Omit<InstanceType<ImplClassWithAbstract>, keyof Abstract>,
|
||||||
ConstructorParameters<ImplClassWithAbstract>
|
ConstructorParameters<ImplClassWithAbstract>
|
||||||
> &
|
> &
|
||||||
Omit<StaticMembers<ImplClassWithAbstract>, typeof isTraitApplierSuper>
|
Omit<StaticMembers<ImplClassWithAbstract>, "_tag">
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -137,14 +137,12 @@ export namespace Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export type TraitApplierSuperTag = "@thilawyn/traitify-ts/TraitApplierSuper"
|
|
||||||
|
|
||||||
export function trait<
|
export function trait<
|
||||||
Abstract extends {},
|
Abstract extends {},
|
||||||
ImplClassWithAbstract extends Class<Abstract, []> & { [isTraitApplierSuper]: true },
|
ImplClassWithAbstract extends Class<Abstract, []> & { _tag: TraitApplierSuperTag },
|
||||||
>(
|
>(
|
||||||
abstract: Opaque<Abstract, AbstractTag>,
|
abstract: Opaque<Abstract, AbstractTag>,
|
||||||
apply: (Super: AbstractClass<Abstract> & { [isTraitApplierSuper]: true }) => ImplClassWithAbstract,
|
apply: (Super: AbstractClass<Abstract> & { _tag: TraitApplierSuperTag }) => ImplClassWithAbstract,
|
||||||
) {
|
) {
|
||||||
return new Trait(
|
return new Trait(
|
||||||
emptyTraitExpression,
|
emptyTraitExpression,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Call, Fn, Pipe, Tuples } from "hotscript"
|
import { Call, Fn, Pipe, Tuples } from "hotscript"
|
||||||
import { AbstractClass, Class, Opaque } from "type-fest"
|
import { AbstractClass, Class, Opaque } from "type-fest"
|
||||||
import { AbstractTag, RemoveAbstractFromImplClass, Trait, TraitApplierSuperTag, isTraitApplierSuper } from "."
|
import { AbstractTag, RemoveAbstractFromImplClass, Trait, TraitApplierSuperTag } from "."
|
||||||
import { ExtendFn, SimplifyFn, StaticMembersFn } from "./util"
|
import { ExtendFn, SimplifyFn, StaticMembersFn } from "./util"
|
||||||
|
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ export class TraitExpression<
|
|||||||
subtrait<
|
subtrait<
|
||||||
This extends TraitExpression<typeof TraitExpression.NullSuperclass, any, any>,
|
This extends TraitExpression<typeof TraitExpression.NullSuperclass, any, any>,
|
||||||
SubtraitAbstract extends Implements<This>,
|
SubtraitAbstract extends Implements<This>,
|
||||||
SubtraitImplClassWithAbstract extends Class<SubtraitAbstract, []> & { [isTraitApplierSuper]: true },
|
SubtraitImplClassWithAbstract extends Class<SubtraitAbstract, []> & { _tag: TraitApplierSuperTag },
|
||||||
>(
|
>(
|
||||||
this: This,
|
this: This,
|
||||||
abstract: (expression: This) => Opaque<SubtraitAbstract, AbstractTag>,
|
abstract: (expression: This) => Opaque<SubtraitAbstract, AbstractTag>,
|
||||||
apply: (Super: AbstractClass<SubtraitAbstract> & { [isTraitApplierSuper]: true }) => SubtraitImplClassWithAbstract,
|
apply: (Super: AbstractClass<SubtraitAbstract> & { _tag: TraitApplierSuperTag }) => SubtraitImplClassWithAbstract,
|
||||||
) {
|
) {
|
||||||
return new Trait(
|
return new Trait(
|
||||||
this,
|
this,
|
||||||
|
|||||||
@@ -5,5 +5,4 @@ export {
|
|||||||
trait,
|
trait,
|
||||||
type Trait,
|
type Trait,
|
||||||
type TraitExpression,
|
type TraitExpression,
|
||||||
isTraitApplierSuper,
|
|
||||||
} from "."
|
} from "."
|
||||||
|
|||||||
Reference in New Issue
Block a user