From c9fbb445a756532f44a652b66caee208201d9776 Mon Sep 17 00:00:00 2001 From: Nora Date: Tue, 10 Mar 2026 05:05:39 +0000 Subject: [PATCH] fix(slack-stream): bind lastStreamPayload to local const before spread TypeScript cannot narrow a mutable let variable through a null-check guard when it is used in a spread expression (TS2698: Spread types may only be created from object types). Binding to a local const lets the compiler narrow the type correctly. --- src/slack/monitor/message-handler/dispatch.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/slack/monitor/message-handler/dispatch.ts b/src/slack/monitor/message-handler/dispatch.ts index 9562e8f3027..81f0571587c 100644 --- a/src/slack/monitor/message-handler/dispatch.ts +++ b/src/slack/monitor/message-handler/dispatch.ts @@ -546,9 +546,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. - if (orphanDeleted && lastStreamPayload && streamedText) { + // Bind to a local const so TypeScript narrows away null before spread. + const fallbackPayload = lastStreamPayload; + if (orphanDeleted && fallbackPayload && streamedText) { await deliverNormally( - { ...lastStreamPayload, text: streamedText }, + { ...fallbackPayload, text: streamedText }, finalStream.threadTs, ); }