Skip to content

inject

@tsed/di

Usage

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

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

Overview

ts
function inject<T>(token: TokenProvider<T>, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T;
  • token (TokenProvider<T>): A token provider or token provider group

Description

Inject a provider to another provider.

Use this function to inject a custom provider on constructor parameter or property.

typescript
@Injectable()
export class MyService {
  connection = inject(CONNECTION);
}

Released under the MIT License.