fixes typing
This commit is contained in:
14
readme.md
14
readme.md
@@ -53,19 +53,9 @@ Any valid `Map` key can be used as identifier, but using a class allow the retur
|
||||
```typescript
|
||||
class MyDependency {}
|
||||
|
||||
manager.register(MyDependency, () => new MyDependency());
|
||||
const a = await manager.resolve(MyDependecy); //< `a` is of type `MyDependency`
|
||||
```
|
||||
|
||||
Otherwise you can provide the type as type argument:
|
||||
|
||||
```typescript
|
||||
function provider() {
|
||||
return 'foo'
|
||||
}
|
||||
manager.register('my-dependency-identifier', provider);
|
||||
const a = await manager.resolve('my-dependency-identifier'); //< `a` is of type `unknown`
|
||||
const b = await manager.resolve<string>('my-dependency-identifier'); //< `b` is of type `string`
|
||||
const b = await manager.resolve('dependency-identifier'); //< `b` is of type `unknown`
|
||||
const c = await manager.resolve<number>('dependency-identifier'); //< `c` is of type `number`
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
Reference in New Issue
Block a user