Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (web-api): tweak type of reply_broadcast to be wider #1860

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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