* Resolver for `@inject.setter` * @param ctx * @param injection
(ctx: Context, injection: Injection)
| 452 | * @param injection |
| 453 | */ |
| 454 | function resolveAsSetter(ctx: Context, injection: Injection) { |
| 455 | const targetName = assertTargetType(injection, Function, 'Setter function'); |
| 456 | const bindingSelector = injection.bindingSelector; |
| 457 | if (!isBindingAddress(bindingSelector)) { |
| 458 | throw new Error( |
| 459 | `@inject.setter (${targetName}) does not allow BindingFilter.`, |
| 460 | ); |
| 461 | } |
| 462 | if (bindingSelector === '') { |
| 463 | throw new Error('Binding key is not set for @inject.setter'); |
| 464 | } |
| 465 | // No resolution session should be propagated into the setter |
| 466 | return function setter(value: unknown) { |
| 467 | const binding = findOrCreateBindingForInjection(ctx, injection); |
| 468 | binding!.to(value); |
| 469 | }; |
| 470 | } |
| 471 | |
| 472 | function resolveAsBinding( |
| 473 | ctx: Context, |
nothing calls this directly
no test coverage detected