mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
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:
committed by
Peter Steinberger
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");
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user