typedi

Creator
Creator
Seonglae Cho
Created
Created
2021 Jun 15 5:48
Editor
Edited
Edited
2025 Jul 3 13:41
typedi는 decorator를 이용하여 구현
  • typedi Service
  • typedi Container
  • typedi Inject
  • typedi init
    • import 'reflect-metadata';
      "emitDecoratorMetadata": true, "experimentalDecorators": true,
       
  • typedi example
    • import { Container, Service } from 'typedi'; @Service() class ExampleInjectedService { printMessage() { console.log('I am alive!'); } } @Service() class ExampleService { constructor( // because we annotated ExampleInjectedService with the @Service() // decorator TypeDI will automatically inject an instance of // ExampleInjectedService here when the ExampleService class is requested // from TypeDI. private injectedService: ExampleInjectedService ) {} } const serviceInstance = Container.get(ExampleService); // we request an instance of ExampleService from TypeDI serviceInstance.injectedService.printMessage(); // logs "I am alive!" to the console
       
 
 
 
 

github

 
 

Recommendations