-
Notifications
You must be signed in to change notification settings - Fork 398
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
Not clear where to import Slack types from #1543
Comments
@geoguide - Not sure whether you meant to include something like, import { App } from "@slack/bolt" But that syntax should work. If it helps as well, @misscoded's just added a complete bolt typescript starter template you can play around with as well 🎉 |
No, I want to actually get the types also because I want to type other things. for example
There are other cases where I want to type objects that I am creating with the slack types. |
import { App, Member } from '@slack/bolt'
const { members } = await client.users.list() I see, thanks for the clarification. Wasn't sure if it was just an issue with the import syntax. It's not at all obvious where to go if you're looking for types for Slack Web API calls, which might be the issue here. The users.list response is typed here: https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/response/UsersListResponse.ts and you can import it like this import { UsersListResponse } from '@slack/web-api' If you're looking for the types for either arguments or responses from Slack API calls, you'll want to check out the other types in the We're also considering overhauling the organization of our types across |
That would b super useful! No offense, but it's hard to be confident that the types are the same across bolt and the web API library, and it seems bad to install the web-api library just to get the types. If the types were in their own package, then I'd be confident they were uniform! |
@geoguide - No offense taken! The location of types across our repos has evolved organically (which is a very nice way of saying, we never got around to fully consolidating them). You might have already noticed that we do actually have a standalone package called There's lots of opportunity for us to rethink this experience for TS developers, so I'll take your feedback back to the other maintainers as well. @filmaj @stevengill relevant to the types repo thinkings as of late. |
Also I'm noticing things like the type of a |
@geoguide The message event data types are a bit tricky. The type is a union type of these message event interface so that only the common properties are available unless the event subtype is determined. Please refer to #904 and the other issues linked from the issue. |
I see. Thanks! I'm not a typescript expert, but this seems like another use case for the types so I could do this when I know what kind of message event it is.
Maybe I'm just looking for a more specific event or handler? For now my workaround will do it :) By the way I'm loving the bolt library in general! |
@geoguide As you can see here, there are many subtpes. If you would like to do something only with a newly posted message by humans, you can do the same with this suggestion. In this way, you can access GenericMessageEvent data without casting the type inside the if statement block. app.message(keyword, async ({ message, say }) => {
if (!message.subtype) {
// the `message` is no longer a union type here
await say(`Hi, <@${message.user}>!`);
}
}); If you need to handle messages posted by either humans or other apps' bot users, message.subtype can be either
So glad to hear this! Thank you ❤️ |
Hm, I have to use the suggestion below it which is messier and probably won't continue to work.
Also this doesn't fix the object not having Is there a handler that only fires on user messages? |
Unfortunately, no. I do understand that this is not so easy to handle. However, it is the nature of message events on the platform and we have to ask you to deal with the complexity due to the event delivery design. Please consider picking up the necessary subtype events for your app. It'd be appreciated if you could understand this. |
Description
Unless I'm missing something I can't seem to get the types out of the projects, I'd like to do things like
So I can type other parts of my application, such as results from queries. I don't see an easy way to do this and there aren't types available elsewhere.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version:
node version:
OS version(s):
Steps to reproduce:
Expected result:
What you expected to happen
Actual result:
What actually happened
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
The text was updated successfully, but these errors were encountered: