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:
parent
0eb89b16e1
commit
c9fbb445a7
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user