From 6c381a816379018b34c0a7e0723a9b31f608151b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Sat, 11 Jan 2025 18:34:25 +0100 Subject: [PATCH] fix(core): updated BindToFluentSyntax update BindToFluentSyntax with more flexible factory and provider constraints --- .changeset/hot-vans-begin.md | 5 +++++ .../container/src/binding/models/BindingFluentSyntax.ts | 6 ++++-- .../src/binding/models/BindingFluentSyntaxImplementation.ts | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 .changeset/hot-vans-begin.md diff --git a/.changeset/hot-vans-begin.md b/.changeset/hot-vans-begin.md new file mode 100644 index 0000000..0330050 --- /dev/null +++ b/.changeset/hot-vans-begin.md @@ -0,0 +1,5 @@ +--- +"@inversifyjs/core": minor +--- + +Updated `BindingToSyntax` with more flexible factory and provider constraints diff --git a/packages/container/libraries/container/src/binding/models/BindingFluentSyntax.ts b/packages/container/libraries/container/src/binding/models/BindingFluentSyntax.ts index 1712237..be3fe47 100644 --- a/packages/container/libraries/container/src/binding/models/BindingFluentSyntax.ts +++ b/packages/container/libraries/container/src/binding/models/BindingFluentSyntax.ts @@ -17,12 +17,14 @@ export interface BindToFluentSyntax { toConstantValue(value: T): BindWhenOnFluentSyntax; toDynamicValue(builder: DynamicValueBuilder): BindInWhenOnFluentSyntax; toFactory( - factory: T extends Factory + // eslint-disable-next-line @typescript-eslint/no-explicit-any + factory: T extends Factory ? (context: ResolutionContext) => T : never, ): BindWhenOnFluentSyntax; toProvider( - provider: T extends Provider + // eslint-disable-next-line @typescript-eslint/no-explicit-any + provider: T extends Provider ? (context: ResolutionContext) => T : never, ): BindWhenOnFluentSyntax; diff --git a/packages/container/libraries/container/src/binding/models/BindingFluentSyntaxImplementation.ts b/packages/container/libraries/container/src/binding/models/BindingFluentSyntaxImplementation.ts index 0a6c8e4..6beaa2a 100644 --- a/packages/container/libraries/container/src/binding/models/BindingFluentSyntaxImplementation.ts +++ b/packages/container/libraries/container/src/binding/models/BindingFluentSyntaxImplementation.ts @@ -178,7 +178,8 @@ export class BindToFluentSyntaxImplementation } public toFactory( - builder: T extends Factory + // eslint-disable-next-line @typescript-eslint/no-explicit-any + builder: T extends Factory ? (context: ResolutionContext) => T : never, ): BindWhenOnFluentSyntax { @@ -206,7 +207,8 @@ export class BindToFluentSyntaxImplementation } public toProvider( - provider: T extends Provider + // eslint-disable-next-line @typescript-eslint/no-explicit-any + provider: T extends Provider ? (context: ResolutionContext) => T : never, ): BindWhenOnFluentSyntax {