mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +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
|
||||
const stateService: BrowserStateService = [this as any]
|
||||
.concat(args)
|
||||
.find((arg) => typeof arg.setInSessionMemory === "function");
|
||||
.find(
|
||||
(arg) =>
|
||||
typeof arg.setInSessionMemory === "function" &&
|
||||
typeof arg.getFromSessionMemory === "function"
|
||||
);
|
||||
if (!stateService) {
|
||||
throw new Error(
|
||||
`Cannot decorate ${constructor.name} with browserSession, Browser's StateService must be injected`
|
||||
|
||||
Reference in New Issue
Block a user