vlocode-project - v2.4.5
    Preparing search index...

    Interface InjectableDecorator

    Decorator interface for marking classes as injectable and configuring their lifecycle in the DI container. Provides methods for transient and singleton lifecycles, as well as utilities for property and parameter injection.

    interface InjectableDecorator {
        isDecorated: (serviceType: ObjectType) => boolean;
        param: InjectDecorator;
        property: InjectDecorator;
        singleton: (options?: Omit<DependencyOptions, "lifecycle">) => any;
        transient: (options?: Omit<DependencyOptions, "lifecycle">) => any;
        <T extends new (...args: any[]) => InstanceType<T>>(
            options?: DependencyOptions,
        ): (ctor: T) => any;
    }
    • Decorates a class as injectable, registering it with the DI container.

      Type Parameters

      • T extends new (...args: any[]) => InstanceType<T>

      Parameters

      • Optionaloptions: DependencyOptions

        Optional dependency options, such as lifecycle and provided services.

      Returns (ctor: T) => any

      A class decorator function.

      LifecyclePolicy.singleton when no lifecycle is specified.
      
    Index

    Properties

    isDecorated: (serviceType: ObjectType) => boolean

    Checks if a class type is decorated with the injectable decorator.

    Type Declaration

      • (serviceType: ObjectType): boolean
      • Parameters

        • serviceType: ObjectType

          The class or constructor to check.

        Returns boolean

        True if decorated, false otherwise.

    Parameter injection decorator (deprecated, use @inject instead).

    Use @inject instead

    property: InjectDecorator

    Property injection decorator (deprecated, use @inject instead).

    Use @inject instead

    singleton: (options?: Omit<DependencyOptions, "lifecycle">) => any

    Decorates a class as injectable with a singleton lifecycle (single shared instance).

    Type Declaration

      • (options?: Omit<DependencyOptions, "lifecycle">): any
      • Parameters

        • Optionaloptions: Omit<DependencyOptions, "lifecycle">

          Optional dependency options, excluding lifecycle.

        Returns any

        A class decorator function.

    transient: (options?: Omit<DependencyOptions, "lifecycle">) => any

    Decorates a class as injectable with a transient lifecycle (new instance per resolution).

    Type Declaration

      • (options?: Omit<DependencyOptions, "lifecycle">): any
      • Parameters

        • Optionaloptions: Omit<DependencyOptions, "lifecycle">

          Optional dependency options, excluding lifecycle.

        Returns any

        A class decorator function.