discordx
    Preparing search index...

    Class Modifier<TTarget>

    A powerful system for modifying the behavior of existing decorators without altering their implementation.

    Modifiers allow you to create cross-cutting concerns that can affect multiple decorators based on their type and location. This enables features like development mode overrides, logging, validation, and dynamic behavior changes.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _methodReference?: Record<string, any>
    _parameterIndex?: number
    _propertyName: string
    _sourceClass: Record<string, any>
    _targetClass: Record<string, any>

    Accessors

    • get classRef(): Record<string, any>

      The class constructor where this decorator was applied.

      Returns Record<string, any>

    • set classRef(value: Record<string, any>): void

      Parameters

      • value: Record<string, any>

      Returns void

    • get from(): Record<string, any>

      The original class where the decoration was first applied. May differ from classRef in inheritance scenarios.

      Returns Record<string, any>

    • set from(value: Record<string, any>): void

      Parameters

      • value: Record<string, any>

      Returns void

    • get index(): undefined | number

      The zero-based index of the parameter being decorated (parameter decorators only).

      Returns undefined | number

    • get isClass(): boolean

      Determines if this decorator was applied to a class constructor.

      Returns boolean

    • get key(): string

      The name of the property or method being decorated.

      Returns string

    • get method(): undefined | Record<string, any>

      The actual method function reference (for method decorators).

      Returns undefined | Record<string, any>

    Methods

    • Applies this modifier's function to a specific decorator.

      Parameters

      • targetDecorator: TTarget

        The decorator to modify.

      Returns Promise<void>

      The result of the modification function.

    • Automatically detects the decoration target type and applies appropriate metadata.

      This method handles the complexity of TypeScript's decorator signatures and normalizes them into a consistent internal representation.

      Parameters

      • classConstructor: Record<string, any>

        The class constructor

      • OptionalpropertyKey: string

        Property/method name (undefined for class decorators)

      • OptionalmethodDescriptor: PropertyDescriptor

        Method descriptor (undefined for parameter decorators)

      • OptionalparameterIndex: number

        Parameter index (undefined for class/method decorators)

      Returns this

      This instance for method chaining

    • Manually sets all metadata properties for this decorator.

      Parameters

      • targetClass: Record<string, any>

        The class being decorated

      • propertyName: string

        The property/method name

      • OptionalmethodRef: Record<string, any>

        The method function reference

      • OptionalsourceClass: Record<string, any>

        The originating class (defaults to targetClass)

      • OptionalparameterIndex: number

        The parameter position

      Returns this

      This instance for method chaining

    • Applies a collection of modifiers to a collection of decorators.

      This is the main entry point for the modification system. It processes all modifiers and applies them to their applicable decorators in parallel for better performance.

      Parameters

      • modifierCollection: Modifier<Decorator>[]

        The collection of modifiers to apply.

      • decoratorCollection: Decorator[]

        The collection of decorators to potentially modify.

      Returns Promise<void>

      A promise that resolves when all modifications are applied.