Skip to content

Commit

Permalink
types(test): add a test to not mix up built-in node MessageEvent ty…
Browse files Browse the repository at this point in the history
…pe (#2022)
  • Loading branch information
filmaj committed Sep 10, 2024
1 parent beb0345 commit 2c1a6e6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/types/src/block-kit/composition-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface Confirm {
* @description Defines a dialog that adds a confirmation step to interactive elements.
* @see {@link https://api.slack.com/reference/block-kit/composition-objects#confirm Confirmation dialog object reference}.
*/
export interface ConfirmationDialog extends Confirm { }
export interface ConfirmationDialog extends Confirm {}

/**
* @description Defines when a {@link PlainTextElement} will return a {@link https://api.slack.com/reference/interaction-payloads/block-actions `block_actions` interaction payload}.
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/block-kit/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Action {
action_id?: string;
}

export interface Actionable extends Action { }
export interface Actionable extends Action {}

export interface Confirmable {
/**
Expand Down
25 changes: 25 additions & 0 deletions packages/types/test/events/message.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expectAssignable } from 'tsd';
import type { GenericMessageEvent, MessageDeletedEvent, MessageEvent } from '../../src/index';

const anyMessageEvent: GenericMessageEvent = {
type: 'message',
subtype: undefined,
channel_type: 'channel',
channel: 'C1234',
event_ts: '1234.56',
user: 'U1234',
ts: '1234.56',
};
// don't confuse `MessageEvent` with the built-in node Message event (https://github.com/slackapi/node-slack-sdk/issues/2020)
const messageDeletedEvent: MessageDeletedEvent = {
type: 'message',
subtype: 'message_deleted',
event_ts: '1234.56',
hidden: true,
channel: 'C12345',
channel_type: 'channel',
ts: '1234.56',
deleted_ts: '1234.56',
previous_message: anyMessageEvent,
};
expectAssignable<MessageEvent>(messageDeletedEvent.previous_message);
12 changes: 3 additions & 9 deletions packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": [
"./types/*"
]
"*": ["./types/*"]
},
"esModuleInterop": true
// Not using this setting because its only used to require the package.json file, and that would change the
// structure of the files in the dist directory because package.json is not located inside src. It would be nice
// to use import instead of require(), but its not worth the tradeoff of restructuring the build (for now).
// "resolveJsonModule": true,
},
"include": [
"src/**/*"
],
"exclude": [
"src/**/*.spec.*"
],
"include": ["src/**/*"],
"exclude": ["src/**/*.spec.*"],
"jsdoc": {
"out": "support/jsdoc",
"access": "public"
Expand Down

0 comments on commit 2c1a6e6

Please sign in to comment.