|
1 | | -import { expectType, expectNotType } from 'tsd'; |
| 1 | +import { expectType, expectNotType, expectError } from 'tsd'; |
2 | 2 | import { App, OptionsRequest, OptionsSource } from '../dist'; |
| 3 | +import { Option } from '@slack/types'; |
3 | 4 |
|
4 | 5 | const app = new App({ token: 'TOKEN', signingSecret: 'Signing Secret' }); |
5 | 6 |
|
6 | | -expectType<void>(app.options('action-id-or-callback-id', async ({ options }) => { |
7 | | - expectType<OptionsRequest<OptionsSource>>(options); |
| 7 | +const blockSuggestionOptions: Option[] = [ |
| 8 | + { |
| 9 | + "text": { |
| 10 | + "type": "plain_text", |
| 11 | + "text": "foo" |
| 12 | + }, |
| 13 | + "value": "bar" |
| 14 | + } |
| 15 | +]; |
| 16 | + |
| 17 | +// set the default to block_suggestion |
| 18 | +expectType<void>(app.options('action-id-or-callback-id', async ({ options, ack }) => { |
| 19 | + expectType<OptionsRequest<'block_suggestion'>>(options); |
| 20 | + expectType<never>(options.callback_id); |
| 21 | + options.block_id; |
| 22 | + options.action_id; |
| 23 | + // https://github.com/slackapi/bolt-js/issues/720 |
| 24 | + await ack({ options: blockSuggestionOptions }); |
8 | 25 | await Promise.resolve(options); |
9 | 26 | })); |
10 | 27 |
|
11 | 28 | // block_suggestion |
12 | | -expectType<void>(app.options<'block_suggestion'>({ action_id: 'a' }, async ({ options }) => { |
| 29 | +expectType<void>(app.options<'block_suggestion'>({ action_id: 'a' }, async ({ options, ack }) => { |
13 | 30 | expectNotType<OptionsRequest<OptionsSource>>(options); |
14 | 31 | expectType<OptionsRequest<'block_suggestion'>>(options); |
| 32 | + // https://github.com/slackapi/bolt-js/issues/720 |
| 33 | + await ack({ options: blockSuggestionOptions }); |
15 | 34 | await Promise.resolve(options); |
16 | 35 | })); |
17 | 36 | // FIXME: app.options({ type: 'block_suggestion', action_id: 'a' } does not work |
18 | 37 |
|
19 | 38 | // interactive_message (attachments) |
20 | | -expectType<void>(app.options<'interactive_message'>({ callback_id: 'a' }, async ({ options }) => { |
| 39 | +expectType<void>(app.options<'interactive_message'>({ callback_id: 'a' }, async ({ options, ack }) => { |
21 | 40 | expectNotType<OptionsRequest<OptionsSource>>(options); |
22 | 41 | expectType<OptionsRequest<'interactive_message'>>(options); |
| 42 | + // https://github.com/slackapi/bolt-js/issues/720 |
| 43 | + expectError(ack({ options: blockSuggestionOptions })); |
23 | 44 | await Promise.resolve(options); |
24 | 45 | })); |
25 | 46 |
|
26 | | -expectType<void>(app.options({ type: 'interactive_message', callback_id: 'a' }, async ({ options }) => { |
| 47 | +expectType<void>(app.options({ type: 'interactive_message', callback_id: 'a' }, async ({ options, ack }) => { |
27 | 48 | // FIXME: the type should be OptionsRequest<'interactive_message'> |
28 | 49 | expectType<OptionsRequest<OptionsSource>>(options); |
| 50 | + // https://github.com/slackapi/bolt-js/issues/720 |
| 51 | + expectError(ack({ options: blockSuggestionOptions })); |
29 | 52 | await Promise.resolve(options); |
30 | 53 | })); |
31 | 54 |
|
32 | 55 | // dialog_suggestion (dialog) |
33 | | -expectType<void>(app.options<'dialog_suggestion'>({ callback_id: 'a' }, async ({ options }) => { |
| 56 | +expectType<void>(app.options<'dialog_suggestion'>({ callback_id: 'a' }, async ({ options, ack }) => { |
34 | 57 | expectNotType<OptionsRequest<OptionsSource>>(options); |
35 | 58 | expectType<OptionsRequest<'dialog_suggestion'>>(options); |
| 59 | + // https://github.com/slackapi/bolt-js/issues/720 |
| 60 | + expectError(ack({ options: blockSuggestionOptions })); |
36 | 61 | await Promise.resolve(options); |
37 | 62 | })); |
38 | 63 | // FIXME: app.options({ type: 'dialog_suggestion', callback_id: 'a' } does not work |
0 commit comments