fix: narrow agentEntry type to avoid TS2339 on heartbeat access#30010
fix: narrow agentEntry type to avoid TS2339 on heartbeat access#30010thomasxm wants to merge 0 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryFixes TypeScript TS2339 error by narrowing the type of Confidence Score: 5/5
Last reviewed commit: 3d3fff2 |
Cherry-pick from fix/cron-heartbeat-type-narrowing (PR openclaw#30010) to unblock CI on this branch. The pre-existing bug on main causes `pnpm check` to fail with TS2339 because `Array.isArray(...) && .find(...)` short-circuits to `false | AgentConfig` instead of `AgentConfig | undefined`.
nikolasdehor
left a comment
There was a problem hiding this comment.
Clean minimal fix. The || undefined coercion at the declaration site is the right approach — fixes the type narrowing once. Note: PR #30021 touches this exact line with a different approach; this PR's fix is more idiomatic and should take precedence. LGTM.
|
This pull request has been automatically marked as stale due to inactivity. |
3d3fff2 to
b02a076
Compare
|
Closing this — the TS2339 type-narrowing issue on |
Summary
&&short-circuit fromArray.isArray(runtimeConfig.agents?.list) && .find(...)producesfalse | AgentConfig, causing TypeScript to reject.heartbeataccess with TS2339 even with optional chaining|| undefinedso the type narrows toAgentConfig | undefinedThis is a one-line fix for a CI-blocking type error on
main.Test plan
pnpm buildpasses (no TS2339)pnpm checkpasses🤖 Generated with Claude Code