fix(slack-stream): use !== null narrowing for lastStreamPayload spread

tsgo (native TypeScript compiler) does not narrow a let variable through a
truthy check in a compound && condition when it appears in a spread
expression. Replace the intermediate const + truthy check with an explicit
!== null guard which tsgo reliably narrows.
This commit is contained in:
Nora 2026-03-10 05:43:48 +00:00 committed by Vincent Koc
parent d1653b7750
commit 7b9fc01fba

View File

@ -553,10 +553,8 @@ 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.
// Bind to a local const so TypeScript narrows away null before spread.
const fallbackPayload = lastStreamPayload;
if (orphanDeleted && fallbackPayload && streamedText) {
await deliverNormally({ ...fallbackPayload, text: streamedText }, finalStream.threadTs);
if (orphanDeleted && lastStreamPayload !== null && streamedText) {
await deliverNormally({ ...lastStreamPayload, text: streamedText }, finalStream.threadTs);
}
}
}