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

Incorrect typing for global shortcut parameters #1512

Closed
4 of 10 tasks
NoNameProvided opened this issue Jul 2, 2022 · 1 comment · Fixed by #1849
Closed
4 of 10 tasks

Incorrect typing for global shortcut parameters #1512

NoNameProvided opened this issue Jul 2, 2022 · 1 comment · Fixed by #1849
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific

Comments

@NoNameProvided
Copy link

NoNameProvided commented Jul 2, 2022

Description

The typing for global shortcut handlers is incorrect. The destructured parameter list contains the say and respond methods, but they are undefined during runtime. Those functions being undefined is the correct behavior and aligns with the documentation, but the typing doesn't reflect it.

A minimal code to reproduce:

app.shortcut<GlobalShortcut>('my_global_shortcut', async ({ ack, say }) => {
  await ack();

  /**
   * Typescript doesn't complain that this property doesn't exist, but it should
   * because the `say` function is undefined in runtime.
   */
  await say('My message. This is an invalid call.');
});

PS: The typing is generally very well made and easy to understand a really good job! This can be easily used as an example of how to write great generic typing with auto inferring. Kudos for the engineers who made it!

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: @slack/bolt@3.11.3

node version: v16.13.1 (LTS)

OS version(s): Windows 10 21H1 (OS Build 19043.1766)

Steps to reproduce:

  1. Create an app and register a global shortcut
  2. Configure the HTTP callback endpoints
  3. Create a new project with the snippet from my description
  4. Call the global shortcut from Slack and see the say method is undefined

Expected result:

Typing is correct for global shortcuts and the compilation of the above code fails at build time.

Actual result:

No errors and build time, app raises a TypeError during runtime.

Attachments:

none

@seratch seratch added this to the 3.x milestone Jul 3, 2022
@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific labels Jul 3, 2022
@seratch
Copy link
Member

seratch commented Jul 3, 2022

@NoNameProvided Thanks for taking the time to report this issue. You are right that this is a bug affecting TypeScript users.

seratch added a commit that referenced this issue May 24, 2023
…1849)

* Fixes 1512: Remove say from SlackShortcutMiddlewareArgs for GlobalShortcuts

* Fix comment in test

---------

Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
@filmaj filmaj removed this from the 3.x milestone Nov 14, 2023
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