Skip to content

Commit

Permalink
fix (web-api): tweak type of reply_broadcast to be wider (#1860)
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj authored Jul 31, 2024
1 parent 8f4265d commit 20491c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/web-api/src/types/request/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ interface WithinThreadReply extends Partial<ThreadTS> {
}
interface BroadcastedThreadReply extends ThreadTS {
/** @description Used in conjunction with `thread_ts`, when set to `true` will broadcast the reply to the channel. */
reply_broadcast: true;
reply_broadcast: boolean;
}
// For APIs supporting `reply_broadcast`, there are two options: either a broadcasted threaded reply,
// or not broadcasted. Broadcasted replies are necessarily threaded, so `thread_ts` becomes required.
Expand Down
21 changes: 20 additions & 1 deletion packages/web-api/test/types/methods/chat.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expectError, expectAssignable } from 'tsd';
import { expectAssignable, expectError } from 'tsd';

import { WebClient } from '../../../src/WebClient';

const web = new WebClient('TOKEN');
Expand Down Expand Up @@ -284,6 +285,24 @@ expectAssignable<Parameters<typeof web.chat.postMessage>>([{
thread_ts: '1234.56',
reply_broadcast: true, // can send a threaded message and broadcast it, too
}]);
expectAssignable<Parameters<typeof web.chat.postMessage>>([{
channel: 'C1234',
blocks: [],
thread_ts: '1234.56',
reply_broadcast: false, // can send a threaded message and explicitly not broadcast it
}]);
// adding a test for when `reply_broadcast` specific boolean value is not known ahead of time
// https://github.com/slackapi/node-slack-sdk/issues/1859
function wideBooleanTest(b: boolean) {
expectAssignable<Parameters<typeof web.chat.postMessage>>([{
channel: 'C1234',
blocks: [],
thread_ts: '1234.56',
reply_broadcast: b, // can reply_broadcast be parameterized?
}]);
}
wideBooleanTest(true);
wideBooleanTest(false);

// chat.scheduleMessage
// -- sad path
Expand Down

0 comments on commit 20491c8

Please sign in to comment.