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.
This commit is contained in:
Nora
2026-03-10 05:05:39 +00:00
committed by Vincent Koc
parent 0eb89b16e1
commit c9fbb445a7

View File

@@ -546,9 +546,11 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag
} }
// Fall back to normal delivery with the full accumulated streamed text // Fall back to normal delivery with the full accumulated streamed text
// so the user receives the complete answer even when stop() fails. // 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( await deliverNormally(
{ ...lastStreamPayload, text: streamedText }, { ...fallbackPayload, text: streamedText },
finalStream.threadTs, finalStream.threadTs,
); );
} }