From f2e0997edee38be2fc82a08fed361112a2b4aae9 Mon Sep 17 00:00:00 2001 From: Nora Date: Tue, 10 Mar 2026 06:06:13 +0000 Subject: [PATCH] fix(slack-stream): use Object.assign instead of spread for nullable payload tsc strict mode refuses to narrow mutable let variables through spreads even with const binding, !== null guards, and non-null assertions. Object.assign avoids the TS2698 issue entirely since it accepts any source arguments. --- src/slack/monitor/message-handler/dispatch.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/slack/monitor/message-handler/dispatch.ts b/src/slack/monitor/message-handler/dispatch.ts index 4d739bc5354..bf4d862cbec 100644 --- a/src/slack/monitor/message-handler/dispatch.ts +++ b/src/slack/monitor/message-handler/dispatch.ts @@ -553,13 +553,9 @@ 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. - // Use a nested const + if so TypeScript can narrow the type of the - // captured const (not the outer mutable let) before the spread. - if (orphanDeleted && streamedText) { - const fallback = lastStreamPayload; - if (fallback !== null) { - await deliverNormally({ ...fallback, text: streamedText }, finalStream.threadTs); - } + if (orphanDeleted && lastStreamPayload && streamedText) { + const fallback: ReplyPayload = Object.assign({}, lastStreamPayload, { text: streamedText }); + await deliverNormally(fallback, finalStream.threadTs); } } }