app.message payload arg compatibility in TypeScript
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 445
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 28
Description
The message argument in app.message listeners does not provide sufficient properties in TypeScript.
Property 'user' does not exist on type 'KnownEventFromType<"message">'. Property 'user' does not exist on type 'MessageChangedEvent'.ts(2339)
A workaround is to cast the message value by (message as GenericMessageEvent).user but needless to say, this is not great.
I ran into this today also. Trying to use the official example from https://slack.dev/bolt-js/concepts
// This will match any message that contains 👋
app.message(':wave:', async ({ message, say }) => {
await say(`Hello, <@${message.user}>`);
});
and immediately getting a ts compile error. This is not a great first-time experience. Not even sure how to get it working.
Originally posted by @memark in https://github.com/slackapi/bolt-js/issues/826#issuecomment-830565064
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the official app.message example from the issue and inspect the TypeScript event types behind the message listener. Check why the message union omits user for this callback; done means the example compiles without a cast and the relevant message variants remain correctly typed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100