Skip to content

Commit

Permalink
Add a type test verifying #922 is resolved by #878 (#923)
Browse files Browse the repository at this point in the history
* Add a type test verifying #922 is resolved by #878

* Update types-tests/options.test-d.ts
  • Loading branch information
seratch committed May 19, 2021
1 parent 61dbfa7 commit 2c1a1e9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/_basic/ja_listening_responding_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.options('external_action', async ({ options, ack }) => {
if (results) {
let options = [];
// ack 応答 するために options 配列に情報をプッシュ
for (const result in results) {
for (const result of results) {
options.push({
"text": {
"type": "plain_text",
Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/listening_responding_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ app.options('external_action', async ({ options, ack }) => {
if (results) {
let options = [];
// Collect information in options array to send in Slack ack response
for (const result in results) {
for (const result of results) {
options.push({
"text": {
"type": "plain_text",
Expand Down
35 changes: 35 additions & 0 deletions types-tests/options.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,38 @@ expectType<void>(
}),
);
// FIXME: app.options({ type: 'dialog_suggestion', callback_id: 'a' } does not work

const db = {
get: (_teamId: String) => { return [{ label: 'l', value: 'v' }]; },
};

expectType<void>(
// Taken from https://slack.dev/bolt-js/concepts#options
// Example of responding to an external_select options request
app.options('external_action', async ({ options, ack }) => {
// Get information specific to a team or channel
// (modified to satisfy TS compiler)
const results = options.team != null ? await db.get(options.team.id) : [];

if (results) {
// (modified to satisfy TS compiler)
let options: Option[] = [];
// Collect information in options array to send in Slack ack response
for (const result of results) {
options.push({
"text": {
"type": "plain_text",
"text": result.label
},
"value": result.value
});
}

await ack({
"options": options
});
} else {
await ack();
}
})
);

0 comments on commit 2c1a1e9

Please sign in to comment.