From b32b06043b299381d2333f591af792b5ce20ea43 Mon Sep 17 00:00:00 2001 From: dcrusader Date: Thu, 8 Jan 2015 10:40:09 -0800 Subject: [PATCH] Use ghost module pattern from best practices --- di-lite/di-lite.d.ts | 97 ++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/di-lite/di-lite.d.ts b/di-lite/di-lite.d.ts index 946fe9a3f8..356f70c7bc 100644 --- a/di-lite/di-lite.d.ts +++ b/di-lite/di-lite.d.ts @@ -3,56 +3,67 @@ // Definitions by: Timothy Morris // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface DiLite { - version: string; - createContext(): DiCreateContext; - dependencyExpression(depExp: string): string; - entry(name: string, ctx: DiCreateContext): DiEntry; - strategy: DiStrategy; - factory: DiFactory; - utils: DiUtils; -} +declare module DiLite { + interface DiLiteStatic { + version: string; + createContext(): CreateContext; + dependencyExpression(depExp: string): string; + entry(name: string, ctx: CreateContext): any; + strategy: StrategyEnum; + factory: FactoryEnum; + utils: Utils; + } -interface DiCreateContext { - map: Object; - entry(name: string): Object; - register(name: string, type?: any, args?: any): DiEntry; - has(name: string): boolean; - "get"(name: string): any; - create(name: string, args: any): any; - initialize(): void; - clear(): void; - inject(name: string, o: Object, dependencies: string): Object; - ready(o: Function): Object; - ready(o: Object): Object; -} + interface Dictionary { + [index: string]: T; + } -interface DiEntry { - create(newArgs: any): DiEntry; - object(): Object; - object(o: Object): DiEntry; - strategy(s: Function): DiEntry; - type(t: any): DiEntry; - dependencies(d: string): DiEntry; - args(a: any): DiEntry; - factory(f: Function): DiEntry; -} + interface CreateContext { + map: Dictionary; + entry(name: string): T; + register(name: string, service: T): Entry; + has(name: string): boolean; + get(name: string): any; + create(name: string, args: any): T; + initialize(): void; + clear(): void; + inject(name: string, o: T, dependencies: string): T; + ready(o: Function): T; + ready(o: any): T; + } -interface DiStrategy { - proto(name: string, object: Object, type: any, args: any, ctx: DiCreateContext, dependencies: string): Object; - singleton(name: string, object: Object, type: any, args: any, ctx?: DiCreateContext, dependencies?: string): Object; -} + interface Entry { + create(newArgs: any): Entry; + object(o: T): Entry; + object(): T; + strategy(s: Function): Entry; + strategy(): T; + type(t: T): Entry; + type(): T; + dependencies(d: T): Entry; + dependencies(): T; + args(a: T): Entry; + args(): T; + factory(f: Function): Entry; + factory(): T; + } -interface DiFactory { - "constructor"(type: any, args: any): Object; - func(type: any, args: any): any; -} + interface StrategyEnum { + proto(name: string, object: TObject, type: TType, args: any, ctx: CreateContext, dependencies: any): TObject; + singleton(name: string, object: TObject, type: TType, args: any, ctx?: CreateContext, dependencies?: any): TObject; + } -interface DiUtils { - invokeStmt(args: any, op: string): string; + interface FactoryEnum { + constructor(type: T, args: any): T; + func(type: T, args: any): T; + } + + interface Utils { + invokeStmt(args: any, op: string): string; + } } declare module "di-lite" { export = di; } -declare var di: DiLite; +declare var di: DiLite.DiLiteStatic;