-
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
Add TypeScript Getting Started equivalent #845
Add TypeScript Getting Started equivalent #845
Conversation
Codecov Report
@@ Coverage Diff @@
## main #845 +/- ##
=======================================
Coverage 65.89% 65.89%
=======================================
Files 13 13
Lines 1173 1173
Branches 343 343
=======================================
Hits 773 773
Misses 334 334
Partials 66 66 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements!
docs/_basic/ja_listening_actions.md
Outdated
@@ -41,7 +41,7 @@ app.action({ action_id: 'select_user', block_id: 'assign_ticket' }, | |||
const result = await app.client.reactions.add({ | |||
token: context.botToken, | |||
name: 'white_check_mark', | |||
timestamp: action.ts, | |||
timestamp: action.action_ts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch but this should be body.message.ts
instead. action_ts
may not be the same with message's ts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thanks for catching that
@@ -37,7 +37,7 @@ app.event('team_join', async ({ event, client }) => { | |||
<div class="secondary-content" markdown="0"> | |||
`message()` リスナーは `event('message')` と等価の機能を提供します。 | |||
|
|||
イベントのサブタイプをフィルタリングしたい場合、組み込みの `matchEventSubtype()` ミドルウェアを使用できます。 `bot_message` や `message_replied` のような一般的なメッセージサブタイプの情報は、[メッセージイベントのドキュメント](https://api.slack.com/events/message#message_subtypes)を参照してください。 | |||
イベントのサブタイプをフィルタリングしたい場合、組み込みの `subtype()` ミドルウェアを使用できます。 `bot_message` や `message_replied` のような一般的なメッセージサブタイプの情報は、[メッセージイベントのドキュメント](https://api.slack.com/events/message#message_subtypes)を参照してください。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch 👍
@@ -17,7 +17,7 @@ Bolt アプリケーションは、トップレベルに `app.client` も持っ | |||
|
|||
```javascript | |||
// September 30, 2019 11:59:59 PM を Unix エポックタイムで表示 | |||
const whenSeptemberEnds = 1569887999; | |||
const whenSeptemberEnds = '1569887999'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, the value is a string
in the TypeScript world. https://github.com/slackapi/node-slack-sdk/blob/%40slack/web-api%406.1.0/packages/web-api/src/methods.ts#L982
"start": "npm run build && node dist/app.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, let's use the MIT license here
"version": "1.0.0", | ||
"description": "Bolt getting started app in TypeScript", | ||
"main": "dist/app.js", | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you picked these up from my example. Many developers may eventually want to use webpack etc but I think it's fine to provide this simple example as the very first step.
const result = await app.client.reactions.add({ | ||
token: context.botToken, | ||
name: 'white_check_mark', | ||
timestamp: action.action_ts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I mentioned above, probably this should be body.message.ts
.
} | ||
|
||
export const isMessageItem = (item: ReactionAddedEvent["item"]): item is ReactionMessageItem => { | ||
return (item as ReactionMessageItem).channel !== undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't checking type === "message"
work here? https://api.slack.com/events/reaction_added
67ec23b
to
175fe8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Summary
A temporary example app to show the basics of using Bolt's type system, with an example using type guards. This example app will change as Bolt's type system improves in the future. There are also some basic documentation changes found while building out these examples.
The basic examples are started but not complete (I wanted to open PR for basic app ASAP). This exposes some of the basic flaws with the larger type system, so it may be useful for finding some areas to improve.
(related to #826)
Requirements (place an
x
in each[ ]
)