Metatell AI Bot - v0.0.10
    Preparing search index...

    Type-safe Service Container for Dependency Injection

    Features:

    • Full type safety with TypeScript - no string-based APIs
    • Automatic type inference using ServiceIdentifier tokens
    • Support for both interface tokens and concrete classes
    • Singleton and transient lifetime management
    • Compile-time type checking for all service registrations and retrievals
    Index

    Constructors

    Methods

    • Get a service from the container with automatic type inference

      Type Parameters

      • T

      Parameters

      • key: new (...args: any[]) => ServiceIdentifier<T>

        Service identifier (interface token or class) - strings are not supported

      Returns T

      Service instance with correct type inferred from the key

      Error if service is not registered

      const messageService = container.get(MessageService) // Type is inferred as IMessageService
      const appSettings = container.get(AppSettings) // Type is inferred as IAppSettings
    • Get a service from the container with automatic type inference

      Type Parameters

      • C extends new (...args: any[]) => any

      Parameters

      • key: C

        Service identifier (interface token or class) - strings are not supported

      Returns InstanceType<C>

      Service instance with correct type inferred from the key

      Error if service is not registered

      const messageService = container.get(MessageService) // Type is inferred as IMessageService
      const appSettings = container.get(AppSettings) // Type is inferred as IAppSettings