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

Better typing for block actions payload #2122

Open
sota1235 opened this issue May 30, 2024 · 3 comments
Open

Better typing for block actions payload #2122

sota1235 opened this issue May 30, 2024 · 3 comments
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality semver:major TypeScript-specific
Milestone

Comments

@sota1235
Copy link

I wish some block action body will have more correct typing.

For example, when I use InteractiveMessage type when I want to handle event for clicking button on message, that's type does not contain container payload. But actually it exists.
I think it's intentional type, here is an official document.
https://api.slack.com/reference/interaction-payloads/block-actions#examples

Is there any blocker to implement this type? If not, I have a motivation to pull request.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@filmaj filmaj added enhancement M-T: A feature request for new functionality TypeScript-specific auto-triage-skip Prevent this issue from being closed due to lack of activity and removed untriaged labels May 30, 2024
@filmaj
Copy link
Contributor

filmaj commented May 30, 2024

I 100% agree with you and we definitely want to improve this!

Some of the underlying node packages that Bolt-JS relies on will need to tackle this feature, first, though. If you are curious, take a look at all the issues in the slackapi/node-slack-sdk repo tagged with the typescript label. Essentially, these payloads would need proper typing and would live in, I think, the @slack/types repo (which lives within the slackapi/node-slack-sdk repo). Specifically, I think slackapi/node-slack-sdk#1395 is the issue tracking adding properly typed payloads to @slack/types.

I am itching to address this but work in this area has taken a backseat to other priorities.

I will leave this issue open until we can add support to the underlying @slack/types package. Once slackapi/node-slack-sdk#1395 is resolved, we can look at leveraging and exposing those in Bolt-JS.

That would be a breaking change, though, I think, so I will also tag this as a major version issue and assign it to the 4.0 bolt milestone.

@filmaj filmaj added this to the 4.0.0 milestone May 30, 2024
@seratch
Copy link
Member

seratch commented May 30, 2024

I agree there are a few areas for improvement in this repo for TypeScript users: https://github.com/slackapi/bolt-js/issues?q=is%3Aissue+is%3Aopen+label%3ATypeScript-specific

Nonetheless, specifically talking about the issue mentioned here, it seems there is some misinterpretation. The interactive message payload is the one for interactions within an attachment, not a block. Block action payload data is defined at https://github.com/slackapi/bolt-js/blob/main/src/types/actions/block-action.ts, and it correctly has all available properties, though its details can be improved. Hope this clarifies.

@filmaj
Copy link
Contributor

filmaj commented May 30, 2024

Ahhh thank you @seratch for the clarification! My apologies, I missed that detail. Though, @sota1235 uses the Interactive Message as only an example; I read the implication in their original message as "this is just one area that is lacking in typing."

We could certainly improve the Interactive Message type; the Block Action base payload used in Bolt does have the container property (though that property's type itself could be better, but that is for a future enhancement).

I feel like there's some way we could have InteractiveMessage extend/reuse BlockAction as there is a lot of duplication between the two; team, enterprise, user, channel, token, response_url and trigger_id seem to be the same across the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality semver:major TypeScript-specific
Projects
None yet
Development

No branches or pull requests

3 participants