Interface ClassFieldDecoratorContext<This, Value>

    Context provided to a class field decorator.

    interface ClassFieldDecoratorContext<This, Value> {
        access: {
            get(object: This): Value;
            has(object: This): boolean;
            set(object: This, value: Value): void;
        };
        kind: "field";
        metadata: DecoratorMetadataObject;
        name: string | symbol;
        private: boolean;
        static: boolean;
        addInitializer(initializer: ((this: This) => void)): void;
    }

    Type Parameters

    • This = unknown

      The type on which the class element will be defined. For a static class element, this will be the type of the constructor. For a non-static class element, this will be the type of the instance.

    • Value = unknown

      The type of the decorated class field.

    Properties

    access: {
        get(object: This): Value;
        has(object: This): boolean;
        set(object: This, value: Value): void;
    }

    An object that can be used to access the current value of the class element at runtime.

    Type declaration

    • get:function
      • Gets the value of the field on the provided object.

        Parameters

        Returns Value

    • has:function
      • Determines whether an object has a property with the same name as the decorated element.

        Parameters

        Returns boolean

    • set:function
      • Sets the value of the field on the provided object.

        Parameters

        Returns void

    kind: "field"

    The kind of class element that was decorated.

    name: string | symbol

    The name of the decorated class element.

    private: boolean

    A value indicating whether the class element has a private name.

    static: boolean

    A value indicating whether the class element is a static (true) or instance (false) element.

    Methods

    • Adds a callback to be invoked either before static initializers are run (when decorating a static element), or before instance initializers are run (when decorating a non-static element).

      Parameters

      • initializer: ((this: This) => void)
          • (this): void
          • Parameters

            Returns void

      Returns void