Getting Started
TypeDI is a dependency injection library for TypeScript and JavaScript.
Installation
Note: This installation guide is for usage with TypeScript, if you wish to use TypeDI without Typescript please read the getting started guide for JavaScript.
To start using TypeDI install the required packages via NPM:
Import the reflect-metadata
package at the first line of your application:
As the last step, you need to enable emitting decorator metadata in your Typescript config. Add these two lines to your tsconfig.json
file under the compilerOptions
key:
Now you are ready to use TypeDI with Typescript!
Basic Usage
The most basic usage is to request an instance of a class definition. TypeDI will check if an instance of the class has been created before and return the cached version or it will create a new instance, cache, and return it.
Last updated