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.
18 lines (17 loc) • 759 B
TypeScript
import { type IContainer, ResolveOneOptions } from '../container/IContainer';
import { ProviderOptions } from '../provider/IProvider';
import { type constructor } from '../utils/basic';
export type WithArgs = {
args: unknown[];
};
export type InjectOptions = Partial<WithArgs>;
export interface IInjector {
resolve<T>(container: IContainer, value: constructor<T>, options?: ProviderOptions): T;
}
export interface IInjectFnResolver<T> {
resolve(s: IContainer, options?: ResolveOneOptions): T;
}
export declare abstract class Injector {
resolve<T>(scope: IContainer, Target: constructor<T>, { args, lazy }?: ProviderOptions): T;
protected abstract createInstance<T>(scope: IContainer, Target: constructor<T>, options?: InjectOptions): T;
}