vlocode-project - v1.40.0-beta-4
    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: {
            (): PropertyDecorator;
            (
                serviceType: ObjectType | LazyObjectType,
            ): (
                target: object,
                propertyKey: undefined | string | symbol,
                parameterIndex?: number,
            ) => any;
        };
        property: {
            (): PropertyDecorator;
            (
                serviceType: ObjectType | LazyObjectType,
            ): (
                target: object,
                propertyKey: undefined | string | symbol,
                parameterIndex?: number,
            ) => any;
        };
        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.

    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.

    param: {
        (): PropertyDecorator;
        (
            serviceType: ObjectType | LazyObjectType,
        ): (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any;
    }

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

    Type Declaration

      • (): PropertyDecorator
      • Marks a property or constructor parameter as injectable. Can be used as a property or parameter decorator. Optional service type to inject (when used as parameter decorator)

        Returns PropertyDecorator

        A property or parameter decorator

      • (
            serviceType: ObjectType | LazyObjectType,
        ): (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any
      • Marks a property or constructor parameter as injectable. Can be used as a property or parameter decorator. Optional service type to inject (when used as parameter decorator)

        Parameters

        Returns (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any

        A property or parameter decorator

    Use @inject instead

    property: {
        (): PropertyDecorator;
        (
            serviceType: ObjectType | LazyObjectType,
        ): (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any;
    }

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

    Type Declaration

      • (): PropertyDecorator
      • Marks a property or constructor parameter as injectable. Can be used as a property or parameter decorator. Optional service type to inject (when used as parameter decorator)

        Returns PropertyDecorator

        A property or parameter decorator

      • (
            serviceType: ObjectType | LazyObjectType,
        ): (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any
      • Marks a property or constructor parameter as injectable. Can be used as a property or parameter decorator. Optional service type to inject (when used as parameter decorator)

        Parameters

        Returns (
            target: object,
            propertyKey: undefined | string | symbol,
            parameterIndex?: number,
        ) => any

        A property or parameter decorator

    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.