fixes typing

This commit is contained in:
Robin Chappatte
2024-05-31 18:05:13 +02:00
parent cc31065348
commit 744d1eb6ef
2 changed files with 8 additions and 14 deletions

View File

@@ -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