# Interface IProvider

Interface
Module
import { IProvider } from "@tsed/di"
Source/packages/di/src/interfaces/IProvider.ts

# Overview

interface IProvider<T = any> {
provide<span class="token punctuation">:</span> <a href="/api/di/interfaces/TokenProvider.html"><span class="token">TokenProvider</span></a><span class="token punctuation">;</span>

type?<span class="token punctuation">:</span> <a href="/api/di/domain/ProviderType.html"><span class="token">ProviderType</span></a> | <span class="token keyword">string</span><span class="token punctuation">;</span>

instance?<span class="token punctuation">:</span> T<span class="token punctuation">;</span>

deps?<span class="token punctuation">:</span> <a href="/api/di/interfaces/TokenProvider.html"><span class="token">TokenProvider</span></a><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

useClass?<span class="token punctuation">:</span> <a href="/api/core/domain/Type.html"><span class="token">Type</span></a>&lt;T&gt;<span class="token punctuation">;</span>

useFactory?<span class="token punctuation">:</span> Function<span class="token punctuation">;</span>

useAsyncFactory?<span class="token punctuation">:</span> Function<span class="token punctuation">;</span>

useValue?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

scope?<span class="token punctuation">:</span> <a href="/api/di/domain/ProviderScope.html"><span class="token">ProviderScope</span></a><span class="token punctuation">;</span>

resolvers?<span class="token punctuation">:</span> <a href="/api/di/interfaces/DIResolver.html"><span class="token">DIResolver</span></a><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token punctuation">[</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

}

# Members

provide: TokenProvider;

An injection token. (Typically an instance of Type or InjectionToken, but can be any).


type?: ProviderType | string;

Provider type


instance?: T;

Instance build by the injector


deps?: TokenProvider[];

Define dependencies to build the provider


useClass?: Type<T>;

Class to instantiate for the token.


useFactory?: Function;

Provide a function to build the provider


useAsyncFactory?: Function;

Provide an async function to build the provider


useValue?: any;

Provide predefined value


scope?: ProviderScope;

Scope used by the injector to build the provider.


resolvers?: DIResolver[];

A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.


[key: string]: any;

Other topics