Skip to content
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

Merged
merged 6 commits into from
Mar 23, 2021

Conversation

shaydewael
Copy link
Contributor

@shaydewael shaydewael commented Mar 22, 2021

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 [ ])

@gitwave gitwave bot added the untriaged label Mar 22, 2021
@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #845 (0e3e8cf) into main (0e469c9) will not change coverage.
The diff coverage is n/a.

❗ Current head 0e3e8cf differs from pull request most recent head 175fe8e. Consider uploading reports for the commit 175fe8e to get more accurate results
Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e469c9...175fe8e. Read the comment docs.

@shaydewael shaydewael requested a review from seratch March 22, 2021 23:09
@shaydewael shaydewael added area:examples issues related to example or sample code docs M-T: Documentation work only TypeScript-specific and removed untriaged labels Mar 22, 2021
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements!

@@ -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,
Copy link
Member

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.

Copy link
Contributor Author

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)を参照してください。
Copy link
Member

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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"start": "npm run build && node dist/app.js"
},
"author": "",
"license": "ISC",
Copy link
Member

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": {
Copy link
Member

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,
Copy link
Member

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;
Copy link
Member

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

@seratch seratch added this to the 3.4.0 milestone Mar 23, 2021
@shaydewael shaydewael force-pushed the add-typescript-getting-started branch from 67ec23b to 175fe8e Compare March 23, 2021 01:56
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:examples issues related to example or sample code docs M-T: Documentation work only TypeScript-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants