Bolt-js: MessageEvent type missing `user`

Created on 29 Jan 2021  路  2Comments  路  Source: slackapi/bolt-js

Description

Describe your issue here.

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

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

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

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

Bug Report

MessageEvent type mission user

Reproducible in:

package version: 3.1.1

node version: 14.1

OS version(s): MacOS 11.1

Steps to reproduce:

  1. Define an app.message("hello", async ({ message, say }) => { ... listener.
  2. Try to access message.user

Expected result:

The type of message argument should have the user property.

Actual result:

Property 'user' does not exist on type 'MessageEvent'.
Property 'user' does not exist on type 'MessageChangedEvent'.

Full reproduction code:

import { App } from "@slack/bolt";

const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
});

// Listens to incoming messages that contain "goodbye"
app.message("hello", async ({ message, say }) => {
  // say() sends a message to the channel where the event was triggered
  await say(`hello,  <@${message.user}> :wave:`);
});

(async () => {
  await app.start(process.env.PORT || 3000);
  console.log("Bolt app is running!");
})();

Workaround

Add assertion like this: (message as GenericMessageEvent).user

bug

Most helpful comment

Hey @sunakane, thanks for taking the time to report this issue! It seems that you are right. This should be a bug introduced by https://github.com/slackapi/bolt-js/pull/709. The Slack team will fix this issue shortly but, if you are interested in making a pull request for this, we are happy to be reviewers on it 馃憢

All 2 comments

Hey @sunakane, thanks for taking the time to report this issue! It seems that you are right. This should be a bug introduced by https://github.com/slackapi/bolt-js/pull/709. The Slack team will fix this issue shortly but, if you are interested in making a pull request for this, we are happy to be reviewers on it 馃憢

Fixed by #782 - let me close this issue now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacklein picture jacklein  路  4Comments

theomelo picture theomelo  路  3Comments

dschinkel picture dschinkel  路  4Comments

dschinkel picture dschinkel  路  4Comments

simonsayscode picture simonsayscode  路  3Comments