mirror of
https://github.com/stablyai/orca.git
synced 2026-09-25 08:02:31 +00:00
fix(agent-status): replace Reflect.get with typed property access in legacy freeze helper
9ab0a18e82 (#20716) added src/shared/agent-status-legacy-adapter.ts with a
freezeRecursively helper that reads each own key via Reflect.get, which trips
the anti-slop/no-reflect-get static-analysis rule. That rule is currently
failing CI on downstream PRs that rebase onto main via the merge ref.
Narrow `value` to Record<PropertyKey, unknown> once (TypeScript's `object`
type has no index signature, so this needs one assertion) and read each own
key with typed bracket access instead of Reflect.get. Bracket access on an
own key behaves identically to Reflect.get for both string and symbol keys,
so the helper still freezes every reachable value in the graph exactly as
before.
This commit is contained in:
@@ -91,8 +91,10 @@ function freezeRecursively(value: unknown, seen: WeakSet<object>): void {
|
||||
return
|
||||
}
|
||||
seen.add(value)
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the typeof switch and null check above leave only a non-null object here; Reflect.ownKeys enumerates only that object's own keys, so this assertion only restores the indexable shape TypeScript's `object` type erases.
|
||||
const ownProperties = value as Record<PropertyKey, unknown>
|
||||
for (const key of Reflect.ownKeys(value)) {
|
||||
freezeRecursively(Reflect.get(value, key), seen)
|
||||
freezeRecursively(ownProperties[key], seen)
|
||||
}
|
||||
Object.freeze(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user