diff --git a/src/types.ts b/src/types.ts index e58bf9b..81ce972 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,7 +10,7 @@ export type DependencyArray = DependencyKey[]; export type Scope = 'singleton' | 'transient' | 'scoped'; -export interface Container { +interface Bindable { bind(key: DependencyKey): { toValue: (value: unknown) => void; toFunction: (fn: CallableFunction) => void; @@ -31,7 +31,9 @@ export interface Container { scope?: Scope ) => void; }; +} +export interface Container extends Bindable { load(moduleKey: ModuleKey, module: Module): void; get(key: DependencyKey): T; @@ -41,28 +43,7 @@ export interface Container { runInScope(callback: () => T): T; } -export interface Module { - bind(key: DependencyKey): { - toValue: (value: unknown) => void; - toFunction: (fn: CallableFunction) => void; - toHigherOrderFunction: ( - fn: CallableFunction, - dependencies?: DependencyArray | DependencyObject, - scope?: Scope - ) => void; - toCurry: ( - fn: CallableFunction, - dependencies?: DependencyArray | DependencyObject, - scope?: Scope - ) => void; - toFactory: (factory: CallableFunction, scope?: Scope) => void; - toClass: ( - constructor: new (...args: any[]) => C, - dependencies?: DependencyArray | DependencyObject, - scope?: Scope - ) => void; - }; - +export interface Module extends Bindable { bindings: Map; }