mirror of https://github.com/openclaw/openclaw.git
refactor: use ??= operator for cleaner globalThis singleton init
Addresses greptile review: collapses the if-guard + assignment into a single ??= expression so TypeScript can narrow the type without a non-null assertion.
This commit is contained in:
parent
0d8beeb4e5
commit
d0a3743abd
|
|
@ -213,10 +213,10 @@ export type InternalHookHandler = (event: InternalHookEvent) => Promise<void> |
|
|||
const _g = globalThis as typeof globalThis & {
|
||||
__openclaw_internal_hook_handlers__?: Map<string, InternalHookHandler[]>;
|
||||
};
|
||||
if (!_g.__openclaw_internal_hook_handlers__) {
|
||||
_g.__openclaw_internal_hook_handlers__ = new Map<string, InternalHookHandler[]>();
|
||||
}
|
||||
const handlers = _g.__openclaw_internal_hook_handlers__;
|
||||
const handlers = (_g.__openclaw_internal_hook_handlers__ ??= new Map<
|
||||
string,
|
||||
InternalHookHandler[]
|
||||
>());
|
||||
const log = createSubsystemLogger("internal-hooks");
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue