{"repo":"microsoft/tsyringe","free":true,"listed":false,"github":"https://github.com/microsoft/tsyringe","clone":"git clone https://github.com/microsoft/tsyringe.git","description":"Lightweight dependency injection container for JavaScript/TypeScript","language":"TypeScript","stars":5988,"topics":["dependency-injection","dependency","injection","ioc","container","typescript","decorators"],"license":"MIT","category":"deployment-docker-iac","readme_excerpt":"TSyringe A lightweight dependency injection container for TypeScript/JavaScript for constructor injection. - TSyringe - Installation - API - Decorators - injectable() - singleton() - autoInjectable() - inject() - injectAll() - injectWithTransform() - injectAllWithTransform() - scoped() - Container - Injection Token - Providers - Register - Registry - Resolution - IsRegistered - Interception - Child Containers - Clearing Instances - Circular dependencies - The delay helper function - Interfaces and circular dependencies - Disposable instances - Full examples - Example without interfaces - Example with interfaces - Injecting primitive values (Named injection) - Non goals - Contributing Installation Install by npm or install with yarn (this project is developed using yarn ) Modify your tsconfig.json to include the following settings Add a polyfill for the Reflect API (examples below use reflect-metadata). You can use: - reflect-metadata - core-js (core-js/es7/reflect) - reflection The Reflect polyfill import should only be added once, and before DI is used: Babel If you're using Babel (e.g. using React Native), you will need to configure it to emit TypeScript metadata. First get the Babel plugin Yarn npm Then add it to your Babel config API TSyringe performs Constructor Injection on the constructors of decorated classes. Decorators injectable() Class decorator factory that allows the class' dependencies to be injected at runtime. TSyringe relies on several decorators in order to","default_branch":null,"files":null,"tree":[],"storefront":"/r/microsoft","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/microsoft/tsyringe/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}