Skip to content

Commit

Permalink
Merge 9f4ea32 into 65b2de7
Browse files Browse the repository at this point in the history
  • Loading branch information
Benzo-Fury committed Nov 28, 2023
2 parents 65b2de7 + 9f4ea32 commit 9c7945f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -52,6 +52,7 @@ Awilix enables you to write **composable, testable software** using dependency i
- [`container.build()`](#containerbuild)
- [`container.dispose()`](#containerdispose)
- [Universal Module (Browser Support)](#universal-module-browser-support)
- [Typescript Declarations](#typescript-declarations)
- [Ecosystem](#ecosystem)
- [Contributing](#contributing)
- [What's in a name?](#whats-in-a-name)
Expand Down Expand Up @@ -1346,6 +1347,26 @@ because they depend on Node-specific packages.
- Safari >= 10
- Internet Explorer is not supported
# Typescript Declarations
If you're utilizing [TypeScript](https://www.typescriptlang.org/) and want type information on your dependencies after retrieval, or if you simply want IntelliSense support, you can craft a declaration file as follows:
```ts
// awilix.d.ts
import { AwilixContainer } from "awilix";
import { MyServiceA } from "myServiceA.js";
import { MyServiceB } from "myServiceB.js";

interface DependencyMap {
serviceA: MyServiceA;
serviceB: MyServiceA;
}

declare module "awilix" {
function createContainer<T extends DependencyMap = DependencyMap>(
opts?: ContainerOptions<T>
): AwilixContainer<T>;
}
```
# Ecosystem
* [`awilix-manager`](https://github.com/kibertoad/awilix-manager): Wrapper that allows eager injection, asynchronous init methods and dependency lookup by tags.
Expand Down

0 comments on commit 9c7945f

Please sign in to comment.