Package
@slack/types
SDK Version
@slack/types@3.2.0
Node.js Version
N/A (type definition issue)
Operating System
No response
Steps to Reproduce
- Set up an app subscribed to the
message.channels event.
- Start a thread in a channel where the app is a member.
- Reply in that thread. Attach a file and check "Also send to #channel".
- Inspect the payload of the
message event the app receives.
In TypeScript, the following code does not compile:
import type { ThreadBroadcastMessageEvent } from "@slack/types";
function handle(event: ThreadBroadcastMessageEvent) {
event.files; // error TS2339: Property 'files' does not exist on type 'ThreadBroadcastMessageEvent'
}
Expected Result
ThreadBroadcastMessageEvent defines files?: File[], upload?: boolean, display_as_bot?: boolean and parent_user_id?: string. Slack sends these fields, so we can access them without a type assertion.
Actual Result
Slack sends a message event with subtype: "thread_broadcast". The event includes files, upload, display_as_bot and parent_user_id:
{
"type": "message",
"subtype": "thread_broadcast",
"user": "U0XXXXXXX",
"text": "broadcast with a file",
"ts": "1791448977.697319",
"thread_ts": "1791447929.601119",
"channel": "C0XXXXXXX",
"channel_type": "channel",
"event_ts": "1791448977.697319",
"client_msg_id": "...",
"parent_user_id": "U0XXXXXXX",
"display_as_bot": false,
"upload": false,
"files": [{ "id": "F0XXXXXXX", "name": "image.png", "filetype": "png", ... }],
"root": { ... },
"blocks": [ ... ]
}
However, ThreadBroadcastMessageEvent does not define any of these four fields:
|
export interface ThreadBroadcastMessageEvent { |
|
type: 'message'; |
|
subtype: 'thread_broadcast'; |
|
event_ts: string; |
|
text: string; |
|
attachments?: MessageAttachment[]; |
|
blocks?: (KnownBlock | Block)[]; |
|
user: string; |
|
ts: string; |
|
thread_ts?: string; |
|
root: (GenericMessageEvent | BotMessageEvent) & { |
|
thread_ts: string; |
|
reply_count: number; |
|
reply_users_count: number; |
|
latest_reply: string; |
|
reply_users: string[]; |
|
}; |
|
client_msg_id: string; |
|
channel: string; |
|
channel_type: ChannelTypes; |
|
} |
In the same file, GenericMessageEvent defines files and parent_user_id, and FileShareMessageEvent defines all four.
Package
@slack/types
SDK Version
@slack/types@3.2.0
Node.js Version
N/A (type definition issue)
Operating System
No response
Steps to Reproduce
message.channelsevent.messageevent the app receives.In TypeScript, the following code does not compile:
Expected Result
ThreadBroadcastMessageEventdefinesfiles?: File[],upload?: boolean,display_as_bot?: booleanandparent_user_id?: string. Slack sends these fields, so we can access them without a type assertion.Actual Result
Slack sends a
messageevent withsubtype: "thread_broadcast". The event includesfiles,upload,display_as_botandparent_user_id:{ "type": "message", "subtype": "thread_broadcast", "user": "U0XXXXXXX", "text": "broadcast with a file", "ts": "1791448977.697319", "thread_ts": "1791447929.601119", "channel": "C0XXXXXXX", "channel_type": "channel", "event_ts": "1791448977.697319", "client_msg_id": "...", "parent_user_id": "U0XXXXXXX", "display_as_bot": false, "upload": false, "files": [{ "id": "F0XXXXXXX", "name": "image.png", "filetype": "png", ... }], "root": { ... }, "blocks": [ ... ] }However,
ThreadBroadcastMessageEventdoes not define any of these four fields:node-slack-sdk/packages/types/src/events/message.ts
Lines 276 to 296 in b3190fd
In the same file,
GenericMessageEventdefinesfilesandparent_user_id, andFileShareMessageEventdefines all four.