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.
This commit is contained in:
Nora
2026-03-10 06:06:13 +00:00
committed by Vincent Koc
parent 3c5f308487
commit f2e0997ede

View File

@@ -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);
}
}
}