UNPKG

ts-ioc-container

Version:

Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.

29 lines (28 loc) 1.35 kB
import { DependencyKey, IContainer } from '../container/IContainer'; import type { IProvider, ResolveDependency } from '../provider/IProvider'; import { IRegistration, ProviderPipe, ScopeMatchRule } from './IRegistration'; import { BindToken } from '../token/BindToken'; import { type MapFn } from '../utils/fp'; import { type constructor } from '../utils/basic'; export declare class Registration<T = any> implements IRegistration<T> { private createProvider; key?: DependencyKey | undefined; private scopeRules; static fromClass<T>(Target: constructor<T>, { name }?: { name?: string; }): IRegistration<any>; static fromValue<T>(value: T): IRegistration<any> | Registration<T>; static fromFn<T>(fn: ResolveDependency<T>): Registration<T>; static fromKey<T>(key: DependencyKey): Registration<T>; private mappers; private aliases; constructor(createProvider: () => IProvider<T>, key?: DependencyKey | undefined, scopeRules?: ScopeMatchRule[]); bindToKey(key: DependencyKey): this; bindToAlias(alias: DependencyKey): this; pipe(...mappers: (MapFn<IProvider<T>> | ProviderPipe<T>)[]): this; when(...predicates: ScopeMatchRule[]): this; bindTo(key: DependencyKey | BindToken): this; private matchScope; applyTo(container: IContainer): void; getKeyOrFail(): DependencyKey; }