UNPKG

2.34 kBTypeScriptView Raw
1import { Context } from './context';
2import { ResolutionSession } from './resolution-session';
3import { BoundValue, Constructor, MapObject, ValueOrPromise } from './value-promise';
4/**
5 * Create an instance of a class which constructor has arguments
6 * decorated with `@inject`.
7 *
8 * The function returns a class when all dependencies were
9 * resolved synchronously, or a Promise otherwise.
10 *
11 * @param ctor - The class constructor to call.
12 * @param ctx - The context containing values for `@inject` resolution
13 * @param session - Optional session for binding and dependency resolution
14 * @param nonInjectedArgs - Optional array of args for non-injected parameters
15 */
16export declare function instantiateClass<T extends object>(ctor: Constructor<T>, ctx: Context, session?: ResolutionSession, nonInjectedArgs?: any[]): ValueOrPromise<T>;
17/**
18 * Given a function with arguments decorated with `@inject`,
19 * return the list of arguments resolved using the values
20 * bound in `ctx`.
21
22 * The function returns an argument array when all dependencies were
23 * resolved synchronously, or a Promise otherwise.
24 *
25 * @param target - The class for constructor injection or prototype for method
26 * injection
27 * @param method - The method name. If set to '', the constructor will
28 * be used.
29 * @param ctx - The context containing values for `@inject` resolution
30 * @param session - Optional session for binding and dependency resolution
31 * @param nonInjectedArgs - Optional array of args for non-injected parameters
32 */
33export declare function resolveInjectedArguments(target: object, method: string, ctx: Context, session?: ResolutionSession, nonInjectedArgs?: any[]): ValueOrPromise<BoundValue[]>;
34/**
35 * Given a class with properties decorated with `@inject`,
36 * return the map of properties resolved using the values
37 * bound in `ctx`.
38
39 * The function returns an argument array when all dependencies were
40 * resolved synchronously, or a Promise otherwise.
41 *
42 * @param constructor - The class for which properties should be resolved.
43 * @param ctx - The context containing values for `@inject` resolution
44 * @param session - Optional session for binding and dependency resolution
45 */
46export declare function resolveInjectedProperties(constructor: Function, ctx: Context, session?: ResolutionSession): ValueOrPromise<MapObject<BoundValue>>;