From b2b81d613440bcec4b5e04d0b4571e5e23148e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Tue, 6 Feb 2024 22:33:47 +0100 Subject: [PATCH] Switched branding to string litteral --- src/Trait.ts | 12 +++++------- src/TraitExpression.ts | 6 +++--- src/lib.ts | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Trait.ts b/src/Trait.ts index 4de0dc0..9514d72 100644 --- a/src/Trait.ts +++ b/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 & { [isTraitApplierSuper]: true }, + ImplClassWithAbstract extends Class & { _tag: TraitApplierSuperTag }, Abstract extends {}, > = ( Class< Omit, keyof Abstract>, ConstructorParameters > & - Omit, typeof isTraitApplierSuper> + Omit, "_tag"> ) @@ -137,14 +137,12 @@ export namespace Trait { } -export type TraitApplierSuperTag = "@thilawyn/traitify-ts/TraitApplierSuper" - export function trait< Abstract extends {}, - ImplClassWithAbstract extends Class & { [isTraitApplierSuper]: true }, + ImplClassWithAbstract extends Class & { _tag: TraitApplierSuperTag }, >( abstract: Opaque, - apply: (Super: AbstractClass & { [isTraitApplierSuper]: true }) => ImplClassWithAbstract, + apply: (Super: AbstractClass & { _tag: TraitApplierSuperTag }) => ImplClassWithAbstract, ) { return new Trait( emptyTraitExpression, diff --git a/src/TraitExpression.ts b/src/TraitExpression.ts index 8651ca8..fd0d7ca 100644 --- a/src/TraitExpression.ts +++ b/src/TraitExpression.ts @@ -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, SubtraitAbstract extends Implements, - SubtraitImplClassWithAbstract extends Class & { [isTraitApplierSuper]: true }, + SubtraitImplClassWithAbstract extends Class & { _tag: TraitApplierSuperTag }, >( this: This, abstract: (expression: This) => Opaque, - apply: (Super: AbstractClass & { [isTraitApplierSuper]: true }) => SubtraitImplClassWithAbstract, + apply: (Super: AbstractClass & { _tag: TraitApplierSuperTag }) => SubtraitImplClassWithAbstract, ) { return new Trait( this, diff --git a/src/lib.ts b/src/lib.ts index 8b575d1..9fc1b8f 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -5,5 +5,4 @@ export { trait, type Trait, type TraitExpression, - isTraitApplierSuper, } from "."