@@ -19,9 +19,12 @@ export class ServiceManager implements IServiceManager {
1919 bindings ?: symbol [ ] ,
2020 ) : void {
2121 if ( name ) {
22- this . container . bind < T > ( serviceIdentifier ) . to ( constructor ) . whenTargetNamed ( name ) ;
22+ this . container
23+ . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > )
24+ . to ( constructor )
25+ . whenTargetNamed ( name ) ;
2326 } else {
24- this . container . bind < T > ( serviceIdentifier ) . to ( constructor ) ;
27+ this . container . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > ) . to ( constructor ) ;
2528 }
2629
2730 if ( bindings ) {
@@ -39,7 +42,9 @@ export class ServiceManager implements IServiceManager {
3942 }
4043
4144 public addBinding < T1 , T2 > ( from : identifier < T1 > , to : identifier < T2 > ) : void {
42- this . container . bind ( to ) . toService ( from ) ;
45+ this . container
46+ . bind < T2 > ( to as interfaces . ServiceIdentifier < T2 > )
47+ . toService ( from as interfaces . ServiceIdentifier < T1 > ) ;
4348 }
4449
4550 public addSingleton < T > (
@@ -51,9 +56,16 @@ export class ServiceManager implements IServiceManager {
5156 bindings ?: symbol [ ] ,
5257 ) : void {
5358 if ( name ) {
54- this . container . bind < T > ( serviceIdentifier ) . to ( constructor ) . inSingletonScope ( ) . whenTargetNamed ( name ) ;
59+ this . container
60+ . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > )
61+ . to ( constructor )
62+ . inSingletonScope ( )
63+ . whenTargetNamed ( name ) ;
5564 } else {
56- this . container . bind < T > ( serviceIdentifier ) . to ( constructor ) . inSingletonScope ( ) ;
65+ this . container
66+ . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > )
67+ . to ( constructor )
68+ . inSingletonScope ( ) ;
5769 }
5870
5971 if ( bindings ) {
@@ -69,21 +81,26 @@ export class ServiceManager implements IServiceManager {
6981 name ?: string | number | symbol | undefined ,
7082 ) : void {
7183 if ( name ) {
72- this . container . bind < T > ( serviceIdentifier ) . toConstantValue ( instance ) . whenTargetNamed ( name ) ;
84+ this . container
85+ . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > )
86+ . toConstantValue ( instance )
87+ . whenTargetNamed ( name ) ;
7388 } else {
74- this . container . bind < T > ( serviceIdentifier ) . toConstantValue ( instance ) ;
89+ this . container . bind < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > ) . toConstantValue ( instance ) ;
7590 }
7691 }
7792
7893 public get < T > ( serviceIdentifier : identifier < T > , name ?: string | number | symbol | undefined ) : T {
79- return name ? this . container . getNamed < T > ( serviceIdentifier , name ) : this . container . get < T > ( serviceIdentifier ) ;
94+ return name
95+ ? this . container . getNamed < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > , name )
96+ : this . container . get < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > ) ;
8097 }
8198
8299 public tryGet < T > ( serviceIdentifier : identifier < T > , name ?: string | number | symbol | undefined ) : T | undefined {
83100 try {
84101 return name
85- ? this . container . getNamed < T > ( serviceIdentifier , name )
86- : this . container . get < T > ( serviceIdentifier ) ;
102+ ? this . container . getNamed < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > , name )
103+ : this . container . get < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > ) ;
87104 } catch {
88105 // This might happen after the container has been destroyed
89106 }
@@ -93,8 +110,8 @@ export class ServiceManager implements IServiceManager {
93110
94111 public getAll < T > ( serviceIdentifier : identifier < T > , name ?: string | number | symbol | undefined ) : T [ ] {
95112 return name
96- ? this . container . getAllNamed < T > ( serviceIdentifier , name )
97- : this . container . getAll < T > ( serviceIdentifier ) ;
113+ ? this . container . getAllNamed < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > , name )
114+ : this . container . getAll < T > ( serviceIdentifier as interfaces . ServiceIdentifier < T > ) ;
98115 }
99116
100117 public rebind < T > (
0 commit comments