Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify emitDecoratorMetadata requirement #1693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ You can get the latest release and the type definitions using your preferred pac

`reflect-metadata` will be automatically imported by inversify.

The InversifyJS type definitions are included in the inversify npm package.

> :warning: **Important!** InversifyJS requires TypeScript >= 4.4 and the `experimentalDecorators`, `emitDecoratorMetadata`, compilation options in your `tsconfig.json` file.

```json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
```

InversifyJS requires a modern JavaScript engine with support for:

- [Reflect metadata](https://rbuckton.github.io/reflect-metadata/)
Expand All @@ -93,6 +80,25 @@ If your environment doesn't support one of these you will need to import a shim
Check out the [Environment support and polyfills](https://github.com/inversify/InversifyJS/blob/master/wiki/environment.md)
page in the wiki and the [Basic example](https://github.com/inversify/inversify-basic-example) to learn more.

### TypeScript

The InversifyJS type definitions are included in the inversify npm package.

TypeScript >= 4.4 is required.

Add the `experimentalDecorators` compiler option to your `tsconfig.json`.
Also add `emitDecoratorMetadata` if you want to enable class injection without
`@inject` as described in [Support for classes](https://github.com/inversify/InversifyJS/blob/master/wiki/classes_as_id.md).

```json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
```

## The Basics
Let’s take a look at the basic usage and APIs of InversifyJS with TypeScript:

Expand Down