Skip to content

Commit 2c1a6e6

Browse files
author
Fil Maj
authored
types(test): add a test to not mix up built-in node MessageEvent type (#2022)
1 parent beb0345 commit 2c1a6e6

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

packages/types/src/block-kit/composition-objects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface Confirm {
4949
* @description Defines a dialog that adds a confirmation step to interactive elements.
5050
* @see {@link https://api.slack.com/reference/block-kit/composition-objects#confirm Confirmation dialog object reference}.
5151
*/
52-
export interface ConfirmationDialog extends Confirm { }
52+
export interface ConfirmationDialog extends Confirm {}
5353

5454
/**
5555
* @description Defines when a {@link PlainTextElement} will return a {@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` interaction payload}.

packages/types/src/block-kit/extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface Action {
1515
action_id?: string;
1616
}
1717

18-
export interface Actionable extends Action { }
18+
export interface Actionable extends Action {}
1919

2020
export interface Confirmable {
2121
/**
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expectAssignable } from 'tsd';
2+
import type { GenericMessageEvent, MessageDeletedEvent, MessageEvent } from '../../src/index';
3+
4+
const anyMessageEvent: GenericMessageEvent = {
5+
type: 'message',
6+
subtype: undefined,
7+
channel_type: 'channel',
8+
channel: 'C1234',
9+
event_ts: '1234.56',
10+
user: 'U1234',
11+
ts: '1234.56',
12+
};
13+
// don't confuse `MessageEvent` with the built-in node Message event (https://github.com/slackapi/node-slack-sdk/issues/2020)
14+
const messageDeletedEvent: MessageDeletedEvent = {
15+
type: 'message',
16+
subtype: 'message_deleted',
17+
event_ts: '1234.56',
18+
hidden: true,
19+
channel: 'C12345',
20+
channel_type: 'channel',
21+
ts: '1234.56',
22+
deleted_ts: '1234.56',
23+
previous_message: anyMessageEvent,
24+
};
25+
expectAssignable<MessageEvent>(messageDeletedEvent.previous_message);

packages/types/tsconfig.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@
1616
"moduleResolution": "node",
1717
"baseUrl": ".",
1818
"paths": {
19-
"*": [
20-
"./types/*"
21-
]
19+
"*": ["./types/*"]
2220
},
2321
"esModuleInterop": true
2422
// Not using this setting because its only used to require the package.json file, and that would change the
2523
// structure of the files in the dist directory because package.json is not located inside src. It would be nice
2624
// to use import instead of require(), but its not worth the tradeoff of restructuring the build (for now).
2725
// "resolveJsonModule": true,
2826
},
29-
"include": [
30-
"src/**/*"
31-
],
32-
"exclude": [
33-
"src/**/*.spec.*"
34-
],
27+
"include": ["src/**/*"],
28+
"exclude": ["src/**/*.spec.*"],
3529
"jsdoc": {
3630
"out": "support/jsdoc",
3731
"access": "public"

0 commit comments

Comments
 (0)