File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
packages/runtime/src/interfaces
tests/fixtures/inversify-async Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
- export interface IocContainer {
2
- get < T > ( controller : { prototype : T } ) : T ;
1
+ export type Newable <
2
+ T = unknown ,
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ TArgs extends unknown [ ] = any [ ] ,
5
+ > = new ( ...args : TArgs ) => T ;
6
+
7
+ export type ServiceIdentifier < T = unknown > =
8
+ | string
9
+ | symbol
10
+ | Newable < T >
11
+ // eslint-disable-next-line @typescript-eslint/ban-types
12
+ | Function ;
3
13
4
- get < T > ( controller : { prototype : T } ) : Promise < T > ;
14
+ export interface IocContainer {
15
+ get < T > ( controller : ServiceIdentifier < T > ) : T ;
16
+ get < T > ( controller : ServiceIdentifier < T > ) : Promise < T > ;
5
17
}
6
18
7
19
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Original file line number Diff line number Diff line change 1
- import { Container } from 'inversify' ;
1
+ import { Container , interfaces } from 'inversify' ;
2
2
import { AsyncController } from './asyncController' ;
3
3
import { AsyncService } from './asyncService' ;
4
4
import { AsyncErrorController } from './asyncErrorController' ;
@@ -15,7 +15,7 @@ container.bind('error').toFactory(() => {
15
15
container . bind < AsyncErrorController > ( AsyncErrorController ) . to ( AsyncErrorController ) . inSingletonScope ( ) ;
16
16
17
17
const iocContainer = {
18
- async get < T > ( controller : { prototype : T } ) : Promise < T > {
18
+ async get < T > ( controller : interfaces . ServiceIdentifier < T > ) : Promise < T > {
19
19
return container . get ( controller ) ;
20
20
} ,
21
21
} ;
You can’t perform that action at this time.
0 commit comments