-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainer.d.ts
48 lines (48 loc) · 1.62 KB
/
Container.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
import type { Key, Resolvable } from '.';
export default class Container {
protected bindings: Map<any, any>;
protected instances: Map<any, any>;
protected aliases: Map<any, any>;
/**
* Checks if anything has been bound or aliased into the Container
*/
has(key: Key): boolean;
/**
* Binds a resolvable function into the Container
*
* If it is the only param, the object reference works as the reference key
*/
bind(key: Key | Resolvable<unknown>, resolvable?: unknown | Resolvable<unknown>, shared?: boolean): this;
private resolve;
/**
* Resolves a Binding reference from the Container
*
* If the given key is a Resolvable function,
* it is resolved from the Container on the fly
*/
make(key: unknown, ...params: unknown[]): any;
/**
* Resolves a Binding reference from the Container
*/
get<T extends new (...p: any[]) => InstanceType<T>>(key: T): InstanceType<T>;
get<T>(key: T): T extends new () => infer I ? I : unknown;
/**
* Set an object or primitive value into the Container
*
* When resolved, it returns the same value and reference
*/
instance(key: Key, value: unknown): void;
/**
* Bind a Resolvable function into the Container.
*
* The function is resolved once. Its result is stored
* and returned on subsequent calls to `get` or `make`.
*/
singleton(key: Key, resolvable: unknown): this;
private getInstance;
/**
* Apply an alias to an already-bound binding
*/
alias(alias: unknown, key: Key | Resolvable<unknown>): void;
private getAlias;
}