app.message payload arg compatibility in TypeScript
See original GitHub issueThe 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_
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Documentation - TypeScript 4.6
In a structural type system, object types are compatible based on the members they have. ts. interface Source {. prop: string ...
Read more >TypeScript - Fastify
npm init -y npm i fastify npm i -D typescript @types/node ... When you want to use it for validation of some payload...
Read more >Announcing TypeScript 4.6 - Microsoft Developer Blogs
type Action = | { kind: "NumberContents", payload: number } | { kind: "StringContents", payload: string }; function processAction(action: Action) ...
Read more >How to type Redux actions and Redux reducers in TypeScript?
state, message: action.payload, }; }) // action.payload type is `void` by default when adding reducer function using `addReducer(actionType: string, ...
Read more >TypeScript errors and how to fix them
error TS1055: Type ' AxiosPromise ' is not a valid async function return type in ES5/ES3 because it does not refer to a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s a pity to see that after a year since this issue has been created we still don’t have a ts support of the very basic example in the README 😕
My advice: don’t bother trying to use Bolt with Typescript at this point. Perhaps one day slack will genuinely prioritize Typescript.