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"
|
||||
|
||||
|
||||
export const isTraitApplierSuper = Symbol("isTraitApplierSuper")
|
||||
export type TraitApplierSuperTag = "@thilawyn/traitify-ts/TraitApplierSuper"
|
||||
|
||||
|
||||
export type AddAbstractToImplClass<
|
||||
@@ -19,14 +19,14 @@ export type AddAbstractToImplClass<
|
||||
)
|
||||
|
||||
export type RemoveAbstractFromImplClass<
|
||||
ImplClassWithAbstract extends Class<Abstract, []> & { [isTraitApplierSuper]: true },
|
||||
ImplClassWithAbstract extends Class<Abstract, []> & { _tag: TraitApplierSuperTag },
|
||||
Abstract extends {},
|
||||
> = (
|
||||
Class<
|
||||
Omit<InstanceType<ImplClassWithAbstract>, keyof Abstract>,
|
||||
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<
|
||||
Abstract extends {},
|
||||
ImplClassWithAbstract extends Class<Abstract, []> & { [isTraitApplierSuper]: true },
|
||||
ImplClassWithAbstract extends Class<Abstract, []> & { _tag: TraitApplierSuperTag },
|
||||
>(
|
||||
abstract: Opaque<Abstract, AbstractTag>,
|
||||
apply: (Super: AbstractClass<Abstract> & { [isTraitApplierSuper]: true }) => ImplClassWithAbstract,
|
||||
apply: (Super: AbstractClass<Abstract> & { _tag: TraitApplierSuperTag }) => ImplClassWithAbstract,
|
||||
) {
|
||||
return new Trait(
|
||||
emptyTraitExpression,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Call, Fn, Pipe, Tuples } from "hotscript"
|
||||
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"
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ export class TraitExpression<
|
||||
subtrait<
|
||||
This extends TraitExpression<typeof TraitExpression.NullSuperclass, any, any>,
|
||||
SubtraitAbstract extends Implements<This>,
|
||||
SubtraitImplClassWithAbstract extends Class<SubtraitAbstract, []> & { [isTraitApplierSuper]: true },
|
||||
SubtraitImplClassWithAbstract extends Class<SubtraitAbstract, []> & { _tag: TraitApplierSuperTag },
|
||||
>(
|
||||
this: This,
|
||||
abstract: (expression: This) => Opaque<SubtraitAbstract, AbstractTag>,
|
||||
apply: (Super: AbstractClass<SubtraitAbstract> & { [isTraitApplierSuper]: true }) => SubtraitImplClassWithAbstract,
|
||||
apply: (Super: AbstractClass<SubtraitAbstract> & { _tag: TraitApplierSuperTag }) => SubtraitImplClassWithAbstract,
|
||||
) {
|
||||
return new Trait(
|
||||
this,
|
||||
|
||||
@@ -5,5 +5,4 @@ export {
|
||||
trait,
|
||||
type Trait,
|
||||
type TraitExpression,
|
||||
isTraitApplierSuper,
|
||||
} from "."
|
||||
|
||||
Reference in New Issue
Block a user