• A decorator to register a class in the TSinjex DI (Dependency Injection) container.

    Type Parameters

    • TargetType extends (new (...args: unknown[]) => InstanceType<TargetType>)

      The type of the class to be registered.

    Parameters

    • identifier: Identifier

      The identifier used to register the class in the DI container.

    • Optionaldeprecated: boolean

      If true, the dependency is deprecated and a warning is logged only once upon the first resolution of the dependency.

    Returns ((constructor: TargetType, ...args: unknown[]) => void)

    The decorator function to be applied on the class.

      • (constructor, ...args): void
      • Parameters

        Returns void

    Identifier for more information on identifiers.

    @Register('MyClassIdentifier')
    class MyClass {
    // ...
    }
    @Register('MyClassIdentifier', true)
    class MyClass {
    // ...
    }
  • A decorator to register an instance of a class in the DI (Dependency Injection) container.

    Type Parameters

    • TargetType extends (new (..._args: unknown[]) => InstanceType<TargetType>)

      The type of the class whose instance is to be registered.

    Parameters

    • identifier: Identifier

      The identifier used to register the instance in the DI container.

    • shouldRegister: "instance"

      Set to 'instance' to register the instance in the DI container with an empty constructor.

    • Optionaldeprecated: boolean

      If true, the dependency is deprecated and a warning is logged only once upon the first resolution of the dependency.

    Returns ((constructor: TargetType, ...args: unknown[]) => void)

    The decorator function to be applied on the class.

      • (constructor, ...args): void
      • Parameters

        Returns void

    Identifier for more information on identifiers.

    @RegisterInstance('MyClassInstanceIdentifier', 'instance')
    class MyClass {
    // ...
    }
    @RegisterInstance('MyClassInstanceIdentifier', 'instance', true)
    class MyClass {
    // ...
    }
  • A decorator to register an instance of a class in the DI (Dependency Injection) container.

    Type Parameters

    • TargetType extends (new (..._args: unknown[]) => InstanceType<TargetType>)

      The type of the class whose instance is to be registered.

    Parameters

    • identifier: Identifier

      The identifier used to register the instance in the DI container.

    • Optionalinit: InitDelegate<TargetType & (new (..._args: unknown[]) => InstanceType<TargetType>), InstanceType<TargetType>>

      An optional initializer function which get the constructor of the class as input and returns an instance of the class.

    • Optionaldeprecated: boolean

      If true, the dependency is deprecated and a warning is logged only once upon the first resolution of the dependency.

    Returns ((constructor: TargetType, ...args: unknown[]) => void)

    The decorator function to be applied on the class.

      • (constructor, ...args): void
      • Parameters

        Returns void

    @RegisterInstance('MyClassInstanceIdentifier', (constructor) => new constructor())
    class MyClass {
    // ...
    }
    @RegisterInstance('MyClassInstanceIdentifier', (constructor) => new constructor(), true)
    class MyClass {
    // ...
    }