Skip to content

injectable

@tsed/di

Usage

typescript
import { injectable } from "@tsed/di";

See /packages/di/src/types/common/fn/injectable.ts.

Overview

ts
const injectable: <Token extends import("../index.js").TokenProvider>(token: Token, options?: Partial<import("../index.js").ProviderOpts<import("@tsed/core").Type<any>>>) => {
    alias: (value: string) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    deps: (value: import("../index.js").TokenProvider[]) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    scope: (value: import("../index.js").ProviderScope) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    priority: (value: number) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    path: (value: string) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
    configuration: (value: Partial<TsED.Configuration>) => any & {
        inspect(): Provider<any>;
        store(): import("@tsed/core").Store;
        token(): Token;
        factory(f: (...args: unknown[]) => unknown): any & any;
        asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
        value(v: unknown): any & any;
        class(c: import("@tsed/core").Type<any>): any & any;
    };
} & {
    inspect(): Provider<any>;
    store(): import("@tsed/core").Store;
    token(): Token;
    factory(f: (...args: unknown[]) => unknown): {
        alias: (value: string) => any & any;
        type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
        deps: (value: import("../index.js").TokenProvider[]) => any & any;
        scope: (value: import("../index.js").ProviderScope) => any & any;
        hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
        imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
        priority: (value: number) => any & any;
        path: (value: string) => any & any;
        configuration: (value: Partial<TsED.Configuration>) => any & any;
    } & any;
    asyncFactory(f: (...args: unknown[]) => Promise<unknown>): {
        alias: (value: string) => any & any;
        type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
        deps: (value: import("../index.js").TokenProvider[]) => any & any;
        scope: (value: import("../index.js").ProviderScope) => any & any;
        hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
        imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
        priority: (value: number) => any & any;
        path: (value: string) => any & any;
        configuration: (value: Partial<TsED.Configuration>) => any & any;
    } & any;
    value(v: unknown): {
        alias: (value: string) => any & any;
        type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
        deps: (value: import("../index.js").TokenProvider[]) => any & any;
        scope: (value: import("../index.js").ProviderScope) => any & any;
        hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
        imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
        priority: (value: number) => any & any;
        path: (value: string) => any & any;
        configuration: (value: Partial<TsED.Configuration>) => any & any;
    } & any;
    class(c: import("@tsed/core").Type<any>): {
        alias: (value: string) => any & any;
        type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
        deps: (value: import("../index.js").TokenProvider[]) => any & any;
        scope: (value: import("../index.js").ProviderScope) => any & any;
        hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
        imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
        priority: (value: number) => any & any;
        path: (value: string) => any & any;
        configuration: (value: Partial<TsED.Configuration>) => any & any;
    } & any;
};

alias:

ts
alias: (value: string) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

type:

ts
type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

deps:

ts
deps: (value: import("../index.js").TokenProvider[]) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

scope:

ts
scope: (value: import("../index.js").ProviderScope) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

hooks:

ts
hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

imports:

ts
imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

priority:

ts
priority: (value: number) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

path:

ts
path: (value: string) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

configuration:

ts
configuration: (value: Partial<TsED.Configuration>) => any & {
     inspect(): Provider<any>;
     store(): import("@tsed/core").Store;
     token(): Token;
     factory(f: (...args: unknown[]) => unknown): any & any;
     asyncFactory(f: (...args: unknown[]) => Promise<unknown>): any & any;
     value(v: unknown): any & any;
     class(c: import("@tsed/core").Type<any>): any & any;
 };

ts
} & {

inspect

ts
inspect(): Provider<any>;

store

ts
store(): import("@tsed/core").Store;

token

ts
token(): Token;

factory

ts
factory(f: (...args: unknown[]) => unknown): {
     alias: (value: string) => any & any;
     type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
     deps: (value: import("../index.js").TokenProvider[]) => any & any;
     scope: (value: import("../index.js").ProviderScope) => any & any;
     hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
     imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
     priority: (value: number) => any & any;
     path: (value: string) => any & any;
     configuration: (value: Partial<TsED.Configuration>) => any & any;
 } & any;

asyncFactory

ts
asyncFactory(f: (...args: unknown[]) => Promise<unknown>): {
     alias: (value: string) => any & any;
     type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
     deps: (value: import("../index.js").TokenProvider[]) => any & any;
     scope: (value: import("../index.js").ProviderScope) => any & any;
     hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
     imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
     priority: (value: number) => any & any;
     path: (value: string) => any & any;
     configuration: (value: Partial<TsED.Configuration>) => any & any;
 } & any;

value

ts
value(v: unknown): {
     alias: (value: string) => any & any;
     type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
     deps: (value: import("../index.js").TokenProvider[]) => any & any;
     scope: (value: import("../index.js").ProviderScope) => any & any;
     hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
     imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
     priority: (value: number) => any & any;
     path: (value: string) => any & any;
     configuration: (value: Partial<TsED.Configuration>) => any & any;
 } & any;

class

ts
class(c: import("@tsed/core").Type<any>): {
     alias: (value: string) => any & any;
     type: (value: string | symbol | Function | import("@tsed/core").Type<any> | import("@tsed/core").AbstractType<any>) => any & any;
     deps: (value: import("../index.js").TokenProvider[]) => any & any;
     scope: (value: import("../index.js").ProviderScope) => any & any;
     hooks: (value: Record<string, import("../domain/Provider.js").ProviderHookCallback<any>>) => any & any;
     imports: (value: (import("../index.js").TokenProvider | [import("../index.js").TokenProvider])[]) => any & any;
     priority: (value: number) => any & any;
     path: (value: string) => any & any;
     configuration: (value: Partial<TsED.Configuration>) => any & any;
 } & any;

Released under the MIT License.