Skip to content

app.message payload arg compatibility in TypeScript #904

@seratch

Description

@seratch

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 #826 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScript-specificbugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documenteddocsM-T: Documentation work onlysemver:major

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions