Skip to content

trait

trait<Trait>(token): <T>(target) => T

Defined in: Trait.ts:55

Class decorator that registers a trait on an entity subclass. The type constraint enforces that the class implements all trait members.

@trait(Interactable)
class LightEntity extends Entity {
priority = 4;
interact() { ... } // TS error if missing
}

Trait

TraitToken<Trait>

<T>(target) => T