UNPKG

ts.di

Version:

Typescript写的依赖注入库。An dependency-injection library for TypeScript.

33 lines (32 loc) 1.46 kB
import "reflect-metadata"; export interface Constructor<T extends Object> extends Function { new (...args: any[]): T; readonly constructor: Function; readonly prototype: Object; } export declare type Newable<T> = Constructor<T>; export declare class Injector { static get<T>(ctor: Constructor<T>): T; static setSingleton<T>(ctor: Constructor<T>, val: T, overwrite?: boolean): boolean; static isSingletonExist<T>(ctor: Constructor<T>): boolean; private static getWithFollower<T>(ctor, fllower?); private static create<T>(ctor, follwer?); static registerInjectable<T>(ctor: Constructor<T>): Constructor<T>; static registerSingleton<T>(ctor: Constructor<T>): Constructor<T>; static injectDecoratorFactor(undefOrTypeFunc?: { <T>(): Constructor<T>; }): (target: any, propertyKey: any) => void; static factorOfDecoratorFactor<T>(ctor: Constructor<T>): MethodDecorator; private static factorSymbol; private static isInjectable; private static isSingleton; private static singletonInstance; static checkDependencyLoop: boolean; static strictDecorationCheck: boolean; } export declare function Injectable(): ClassDecorator; export declare function Singleton(): ClassDecorator; export declare function Inject(TypeFunc?: { <T>(_?: any): Constructor<T>; }): PropertyDecorator; export declare function FactorOf<T>(ctor: Constructor<T>): MethodDecorator;