From e3f193e7fb9f7c717502a9691220f1c13d73cf22 Mon Sep 17 00:00:00 2001 From: Konstantin Burov Date: Tue, 26 Nov 2024 21:19:40 +1100 Subject: [PATCH 1/3] Assert returned value type --- src/Container.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Container.ts b/src/Container.ts index a96d7c6..e2e655c 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -421,7 +421,7 @@ export class Container { providesClass = []>( token: Token, cls: InjectableClass - ) => this.providesService(ClassInjectable(token, cls)); + ) => this.providesService(ClassInjectable(token, cls)) as Container>; /** * Registers a static value as a service in the container. This method is ideal for services that do not From 93365db0134fb2abbfceb660c3327e52df49d81f Mon Sep 17 00:00:00 2001 From: Konstantin Burov Date: Wed, 27 Nov 2024 12:40:40 +1100 Subject: [PATCH 2/3] Explicit return type --- src/Container.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Container.ts b/src/Container.ts index e2e655c..87ad6cb 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -421,7 +421,8 @@ export class Container { providesClass = []>( token: Token, cls: InjectableClass - ) => this.providesService(ClassInjectable(token, cls)) as Container>; + ): Container> => + this.providesService(ClassInjectable(token, cls)) as Container>; /** * Registers a static value as a service in the container. This method is ideal for services that do not @@ -433,8 +434,10 @@ export class Container { * @returns A new Container instance that includes the provided service, allowing for chaining additional * `provides` calls. */ - providesValue = (token: Token, value: Service) => - this.providesService(Injectable(token, [], () => value)); + providesValue = ( + token: Token, + value: Service + ): Container> => this.providesService(Injectable(token, [], () => value)); /** * Appends a value to the array associated with a specified token in the current Container, then returns @@ -455,7 +458,7 @@ export class Container { appendValue = >( token: Token, value: Service - ) => this.providesService(ConcatInjectable(token, () => value)) as Container; + ): Container => this.providesService(ConcatInjectable(token, () => value)) as Container; /** * Appends an injectable class factory to the array associated with a specified token in the current Container, @@ -479,7 +482,7 @@ export class Container { >( token: Token, cls: InjectableClass - ) => + ): Container => this.providesService( ConcatInjectable(token, () => this.providesClass(token, cls).get(token)) ) as Container; @@ -507,7 +510,7 @@ export class Container { Service extends ArrayElement, >( fn: InjectableFunction - ) => + ): Container => this.providesService( ConcatInjectable(fn.token, () => this.providesService(fn).get(fn.token)) ) as Container; From b27e2d1b95255ae619cd1042eb9a6fa65094ab22 Mon Sep 17 00:00:00 2001 From: Konstantin Burov Date: Wed, 27 Nov 2024 12:41:28 +1100 Subject: [PATCH 3/3] Bump version up --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8549210..969e9f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snap/ts-inject", - "version": "0.3.1", + "version": "0.3.2", "description": "100% typesafe dependency injection framework for TypeScript projects", "license": "MIT", "author": "Snap Inc.",