Skip to content

Commit

Permalink
fix(core): updated BindToFluentSyntax
Browse files Browse the repository at this point in the history
update BindToFluentSyntax with more flexible factory and provider constraints
  • Loading branch information
notaphplover committed Jan 11, 2025
1 parent bbddebc commit 6c381a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-vans-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inversifyjs/core": minor
---

Updated `BindingToSyntax` with more flexible factory and provider constraints
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export interface BindToFluentSyntax<T> {
toConstantValue(value: T): BindWhenOnFluentSyntax<T>;
toDynamicValue(builder: DynamicValueBuilder<T>): BindInWhenOnFluentSyntax<T>;
toFactory(
factory: T extends Factory<unknown>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
factory: T extends Factory<unknown, any>
? (context: ResolutionContext) => T
: never,
): BindWhenOnFluentSyntax<T>;
toProvider(
provider: T extends Provider<unknown>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
provider: T extends Provider<unknown, any>
? (context: ResolutionContext) => T
: never,
): BindWhenOnFluentSyntax<T>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ export class BindToFluentSyntaxImplementation<T>
}

public toFactory(
builder: T extends Factory<unknown>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
builder: T extends Factory<unknown, any>
? (context: ResolutionContext) => T
: never,
): BindWhenOnFluentSyntax<T> {
Expand Down Expand Up @@ -206,7 +207,8 @@ export class BindToFluentSyntaxImplementation<T>
}

public toProvider(
provider: T extends Provider<unknown>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
provider: T extends Provider<unknown, any>
? (context: ResolutionContext) => T
: never,
): BindWhenOnFluentSyntax<T> {
Expand Down

0 comments on commit 6c381a8

Please sign in to comment.