-
Notifications
You must be signed in to change notification settings - Fork 399
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
using the typescript definitions in an app #588
Comments
I may not fully understand your intention here but just for type-safety, you don't need to maintain your own type definitions. In other words, you cannot do so as long as you use Bolt. If you want import { SlackEventMiddlewareArgs } from '@slack/bolt';
app.message("foo", async (args: SlackEventMiddlewareArgs<'message'>) => {
const event = args.event;
console.log(event);
});
app.message("foo", async ({ event }) => {
console.log(event);
}); |
this maybe worth adding to the docs somewhere. |
If you're using Visual Studio Code, you can easily check the actual type by hovering the arg value. See also: #349 (comment) |
Let me close this issue now. If you have anything further to discuss/ask here, please feel free to reopen and/or write in. |
Description
Typescript typings for incoming events could be extremely helpful in developing an app, however the current typings seem a bit confusing to use.
Are there any examples that show how to use the slack typings on these basic events inside our own apps?
Then I would be able to get intellisense on all the fields that are getting passed in the request.
eg I was trying to add types on the incoming message event, I created my own
ISlackEvent
interface and was going to gradually type it.Which is fair enough since ISlackEvent was my naive type I was going to start adding fields to.
So then researching what there might be...
The message event signature:
Then digging into those Middleware, I can't really see a simple description of the incoming payload.
eventually I get to this humdinger:
export declare type SlackEvent = AppRequestedEvent | AppHomeOpenedEvent | AppMentionEvent | AppUninstalledEvent | ChannelArchiveEvent | ChannelCreatedEvent | ChannelDeletedEvent | ChannelHistoryChangedEvent | ChannelLeftEvent | ChannelRenameEvent | ChannelSharedEvent | ChannelUnarchiveEvent | ChannelUnsharedEvent | DNDUpdatedEvent | DNDUpdatedUserEvent | EmailDomainChangedEvent | EmojiChangedEvent | FileChangeEvent | FileCommentDeletedEvent | FileCreatedEvent | FileDeletedEvent | FilePublicEvent | FileSharedEvent | FileUnsharedEvent | GridMigrationFinishedEvent | GridMigrationStartedEvent | GroupArchiveEvent | GroupCloseEvent | GroupDeletedEvent | GroupHistoryChangedEvent | GroupLeftEvent | GroupOpenEvent | GroupRenameEvent | GroupUnarchiveEvent | IMCloseEvent | IMCreatedEvent | IMHistoryChangedEvent | IMOpenEvent | InviteRequestedEvent | LinkSharedEvent | MemberJoinedChannelEvent | MemberLeftChannelEvent | MessageEvent | PinAddedEvent | PinRemovedEvent | ReactionAddedEvent | ReactionRemovedEvent | StarAddedEvent | StarRemovedEvent | SubteamCreated | SubteamMembersChanged | SubteamSelfAddedEvent | SubteamSelfRemovedEvent | SubteamUpdatedEvent | TeamDomainChangedEvent | TeamJoinEvent | TeamRenameEvent | TokensRevokedEvent | UserChangeEvent;
ahh hmm ok.
So maybe this is the nature of adding typings to a huge API after the fact, but it's quite hard to use these typings to assisting app development. eg related to #587
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: