Resolves a service from the container.
The service identifier (string or symbol)
The resolved service instance
Creates a new scope for scoped services.
Scoped services will have the same instance within a scope, but different instances across different scopes. Useful for request-scoped dependencies in web applications.
A new container scope
const scope = container.createScope();
const service1 = scope.resolve<ScopedService>('scopedService');
const service2 = scope.resolve<ScopedService>('scopedService');
// service1 === service2 (same scope)
const scope2 = container.createScope();
const service3 = scope2.resolve<ScopedService>('scopedService');
// service3 !== service1 (different scope)
Disposes the container and all disposable services.
Services implementing dispose() or Symbol.asyncDispose will have their disposal methods called.
Promise that resolves when all services are disposed
Minimal dependency injection container interface.
Defines the core contract that any DI container must implement. Implementation-agnostic - works with any DI library.
Example