UNPKG

1.38 kBTypeScriptView Raw
1/**
2 * Decorator that marks a constructor parameter as a target for
3 * [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
4 *
5 * Any injected provider must be visible within the module scope (loosely
6 * speaking, the containing module) of the class it is being injected into. This
7 * can be done by:
8 *
9 * - defining the provider in the same module scope
10 * - exporting the provider from one module scope and importing that module into the
11 * module scope of the class being injected into
12 * - exporting the provider from a module that is marked as global using the
13 * `@Global()` decorator
14 *
15 * #### Injection tokens
16 * Can be *types* (class names), *strings* or *symbols*. This depends on how the
17 * provider with which it is associated was defined. Providers defined with the
18 * `@Injectable()` decorator use the class name. Custom Providers may use strings
19 * or symbols as the injection token.
20 *
21 * @param token lookup key for the provider to be injected (assigned to the constructor
22 * parameter).
23 *
24 * @see [Providers](https://docs.nestjs.com/providers)
25 * @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
26 * @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
27 *
28 * @publicApi
29 */
30export declare function Inject<T = any>(token?: T): PropertyDecorator & ParameterDecorator;