Interface ClassDecoratorContext<Class>

    Context provided to a class decorator.

    interface ClassDecoratorContext<Class> {
        kind: "class";
        metadata: DecoratorMetadataObject;
        name: string;
        addInitializer(initializer: ((this: Class) => void)): void;
    }

    Type Parameters

    • Class extends (abstract new (...args: any) => any) = (abstract new (...args: any) => any)

      The type of the decorated class associated with this context.

    Properties

    Methods

    Properties

    kind: "class"

    The kind of element that was decorated.

    name: string

    The name of the decorated class.

    Methods

    • Adds a callback to be invoked after the class definition has been finalized.

      Parameters

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

            Returns void

      Returns void

      function customElement(name: string): ClassDecoratorFunction {
      return (target, context) => {
      context.addInitializer(function () {
      customElements.define(name, this);
      });
      }
      }
      @customElement ("my-element")
      class MyElement {}