From a298fa22f65c23a9c7bf0c76e8bc5909fab7f7e2 Mon Sep 17 00:00:00 2001 From: Nora Date: Tue, 10 Mar 2026 05:48:43 +0000 Subject: [PATCH] fix(slack-stream): non-null assertion for lastStreamPayload spread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tsc does not narrow mutable let variables through spread type expressions even when an explicit !== null guard precedes the spread. The assertion is safe — lastStreamPayload !== null is checked in the same condition. --- src/slack/monitor/message-handler/dispatch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/slack/monitor/message-handler/dispatch.ts b/src/slack/monitor/message-handler/dispatch.ts index f03b1bd8d73..4a8d8b8c43e 100644 --- a/src/slack/monitor/message-handler/dispatch.ts +++ b/src/slack/monitor/message-handler/dispatch.ts @@ -553,8 +553,11 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag } // Fall back to normal delivery with the full accumulated streamed text // so the user receives the complete answer even when stop() fails. + // lastStreamPayload is guarded by !== null above; the ! assertion is + // required because tsc does not narrow mutable let variables through + // spread expressions even with an explicit null guard. if (orphanDeleted && lastStreamPayload !== null && streamedText) { - await deliverNormally({ ...lastStreamPayload, text: streamedText }, finalStream.threadTs); + await deliverNormally({ ...lastStreamPayload!, text: streamedText }, finalStream.threadTs); } } }