mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Check all requirements while duck typing
This commit is contained in:
@@ -24,7 +24,11 @@ export function browserSession<TCtor extends Constructor<any>>(constructor: TCto
|
|||||||
// Require state service to be injected
|
// Require state service to be injected
|
||||||
const stateService: BrowserStateService = [this as any]
|
const stateService: BrowserStateService = [this as any]
|
||||||
.concat(args)
|
.concat(args)
|
||||||
.find((arg) => typeof arg.setInSessionMemory === "function");
|
.find(
|
||||||
|
(arg) =>
|
||||||
|
typeof arg.setInSessionMemory === "function" &&
|
||||||
|
typeof arg.getFromSessionMemory === "function"
|
||||||
|
);
|
||||||
if (!stateService) {
|
if (!stateService) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Cannot decorate ${constructor.name} with browserSession, Browser's StateService must be injected`
|
`Cannot decorate ${constructor.name} with browserSession, Browser's StateService must be injected`
|
||||||
|
|||||||
Reference in New Issue
Block a user