Skip to content

Value

@tsed/di

Usage

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

See /packages/di/src/types/common/decorators/value.ts.

Overview

ts
function Value(expression: string, defaultValue?: unknown): PropertyDecorator;

Description

Return value from Configuration.

Example

typescript
import {Env} from "@tsed/core";
import {Constant, Value} from "@tsed/di";

export class MyClass {

   @Constant("env")
   env: Env;

   @Value("swagger.path")
   swaggerPath: string;

   @Value("swagger.path", "defaultValue")
   swaggerPath: string;

   constructor() {
      console.log(this.swaggerPath) // undefined. Not available on constructor
   }

   $onInit() {
     console.log(this.swaggerPath)  // something
   }
}

Released under the MIT License.