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

ack() is not accessible in global middleware in TypeScript #1478

Closed
4 of 10 tasks
seratch opened this issue Jun 7, 2022 · 2 comments · Fixed by #1482
Closed
4 of 10 tasks

ack() is not accessible in global middleware in TypeScript #1478

seratch opened this issue Jun 7, 2022 · 2 comments · Fixed by #1482
Assignees
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific
Milestone

Comments

@seratch
Copy link
Member

seratch commented Jun 7, 2022

Description

ack() function actually exists in global middleware arguments, but it's not accessible in TypeScript. Note that ack does not exist in middleware args when receiving an Events API payload. It can exist for all the rest.

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

import { App } from '@slack/bolt';
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET
});

app.use(async ({ body, next, ack }) => {
  if (ack && shouldSkip(body)) {
    await ack();
    return;
  }
  await next();
});

Currently, a workaround is to cast the type to any:

app.use(async (args) => {
  const ack = (args as any).ack;
  if (ack && shouldSkip(args.body)) {
    await ack();
    return;
  }
  await args.next();
});

Reproducible in:

package version: any
node version: any
OS version(s): any

Steps to reproduce:

  1. Compile the above code snippet

Expected result:

The ack argument should be available.

Actual result:

Compilation error as below:

@seratch seratch added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented TypeScript-specific labels Jun 7, 2022
@seratch seratch added this to the 3.11.2 milestone Jun 7, 2022
@seratch seratch self-assigned this Jun 7, 2022
@seratch seratch changed the title ack() is not accesible in global middleware in TypeScript ack() is not accessible in global middleware in TypeScript Jun 7, 2022
@seratch
Copy link
Member Author

seratch commented Jun 7, 2022

Additional note: The ack function can be absent for Events API.

@asontha
Copy link

asontha commented Jan 26, 2023

Why is the ack function absent for the Events API?

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.

2 participants