From eb92e58a44a25170f29150aae89b2dfad33a3495 Mon Sep 17 00:00:00 2001 From: "Marcus S. Abildskov" <8391194+marcus-sa@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:30:13 +0100 Subject: [PATCH] feat(injector): improve set method api (#557) * feat(injector): improve set method api * feat(injector): improve injector context set method api --- packages/injector/src/injector.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/injector/src/injector.ts b/packages/injector/src/injector.ts index bcf724267..bea096862 100644 --- a/packages/injector/src/injector.ts +++ b/packages/injector/src/injector.ts @@ -251,7 +251,7 @@ export class Injector implements InjectorInterface { throw new Error(`Invalid get argument given ${token}`); } - set(token: T, value: any, scope?: Scope): void { + set(token: ContainerToken, value: any, scope?: Scope): void { if (!this.setter) throw new Error('Injector was not built'); this.setter(token, value, scope); } @@ -915,7 +915,11 @@ export class InjectorContext { } set(token: T, value: any, module?: InjectorModule): void { - return this.getInjector(module || this.rootModule).set(token, value, this.scope); + return this.getInjector(module || this.rootModule).set( + getContainerToken(token), + value, + this.scope, + ); } static forProviders(providers: ProviderWithScope[]) {