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

BlockAction interface does not include state despite state being present in actual object #1141

Closed
4 of 10 tasks
Richard-PTT opened this issue Oct 4, 2021 · 2 comments · Fixed by #1144
Closed
4 of 10 tasks
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Milestone

Comments

@Richard-PTT
Copy link

Description

BlockAction interface does not include state despite state existing in the payload
When console.logging the body of a button app.action, state is present, and contains my text input values, so the values are clearly present in the payload. However, trying to access it won't work because of Typescript errors.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 3.7.0

node version: 16.3.0

OS version(s): Windows 11

Steps to reproduce:

  1. Create a basic typescript bolt project
  2. Create a block containing a text element and a button
  3. Create an app.action to handle the button click event
  4. Attempt to reference body.state

Expected result:

Reference body.state with no problem

Actual result:

Typescript error: TS2339: Property 'state' does not exist on type 'BlockAction '.

Attachments:

@mwbrooks
Copy link
Member

mwbrooks commented Oct 4, 2021

Hey @Richard-PTT,

Thanks for reporting this TypeScript issue 🙇🏻 Due to the nature of the Slack API payloads, we're still working to improve the types for each response. I'll leave this issue open and let a few of the other maintainers chime in on whether we can improve defining state on a BlockAction type.

In case you're blocked, a workaround for the TypeScript error is to cast the body as type any. While not an ideal solution, I hope it can unblock you:

console.log('body.state:', (body as any).state);

@mwbrooks mwbrooks added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info labels Oct 4, 2021
@seratch seratch added TypeScript-specific and removed needs info An issue that is claimed to be a bug and hasn't been reproduced, or otherwise needs more info labels Oct 5, 2021
@seratch seratch added this to the 3.8.0 milestone Oct 5, 2021
seratch added a commit to seratch/bolt-js that referenced this issue Oct 5, 2021
seratch added a commit to seratch/bolt-js that referenced this issue Oct 5, 2021
@seratch
Copy link
Member

seratch commented Oct 6, 2021

Thanks again for reporting this issue! The issue will be resolved in the next release.

@seratch seratch self-assigned this Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants