forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
di-lite.d.ts
69 lines (61 loc) · 2.02 KB
/
di-lite.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Type definitions for di-lite 0.3.3
// Project: https://github.com/NickQiZhu/di.js
// Definitions by: Timothy Morris <https://github.com/dcrusader>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace DiLite {
interface DiLiteStatic {
version: string;
createContext(): CreateContext;
dependencyExpression(depExp: string): string;
entry(name: string, ctx: CreateContext): any;
strategy: StrategyEnum;
factory: FactoryEnum;
utils: Utils;
}
interface Dictionary<T> {
[index: string]: T;
}
interface CreateContext {
map: Dictionary<any>;
entry<T>(name: string): T;
register<T>(name: string, service: T): Entry;
has(name: string): boolean;
get(name: string): any;
create<T>(name: string, args: any): T;
initialize(): void;
clear(): void;
inject<T>(name: string, o: T, dependencies: string): T;
ready<T>(o: Function): T;
ready<T>(o: any): T;
}
interface Entry {
create(newArgs: any): Entry;
object<T>(o: T): Entry;
object<T>(): T;
strategy<T>(s: Function): Entry;
strategy<T>(): T;
type<T>(t: T): Entry;
type<T>(): T;
dependencies<T>(d: T): Entry;
dependencies<T>(): T;
args<T>(a: T): Entry;
args<T>(): T;
factory(f: Function): Entry;
factory<T>(): T;
}
interface StrategyEnum {
proto<TObject, TType>(name: string, object: TObject, type: TType, args: any, ctx: CreateContext, dependencies: any): TObject;
singleton<TObject, TType>(name: string, object: TObject, type: TType, args: any, ctx?: CreateContext, dependencies?: any): TObject;
}
interface FactoryEnum {
constructor<T>(type: T, args: any): T;
func<T>(type: T, args: any): T;
}
interface Utils {
invokeStmt(args: any, op: string): string;
}
}
declare module "di-lite" {
export = di;
}
declare var di: DiLite.DiLiteStatic;