Skip to content

Commit

Permalink
Merge pull request #166 from aoberoi/fix-block-action-detection
Browse files Browse the repository at this point in the history
Fix block action detection, remove StringIndexed from action body types
  • Loading branch information
shaydewael authored Apr 24, 2019
2 parents 1ed27bb + 40b621a commit 8f9245f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function buildSource(
function isBlockActionOrInteractiveMessageBody(
body: SlackActionMiddlewareArgs['body'],
): body is SlackActionMiddlewareArgs<BlockAction | InteractiveMessage>['body'] {
return (body as SlackActionMiddlewareArgs<BlockAction | InteractiveMessage>['body']).action !== undefined;
return (body as SlackActionMiddlewareArgs<BlockAction | InteractiveMessage>['body']).actions !== undefined;
}

function defaultErrorHandler(logger: Logger): ErrorHandler {
Expand Down
8 changes: 1 addition & 7 deletions src/types/actions/block-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export interface DatepickerAction extends BasicElementAction<'datepicker'> {
*
* This describes the entire JSON-encoded body of a request from Slack's Block Kit interactive components.
*/
export interface BlockAction<ElementAction extends BasicElementAction = BlockElementAction> extends StringIndexed {
export interface BlockAction<ElementAction extends BasicElementAction = BlockElementAction> {
type: 'block_actions';
actions: [ElementAction];
team: {
Expand Down Expand Up @@ -166,9 +166,3 @@ export type BlockChannelsSelectAction = BlockAction<ChannelsSelectAction>;
export type BlockExternalSelectAction = BlockAction<ExternalSelectAction>;
export type BlockOverflowAction = BlockAction<OverflowAction>;
export type BlockDatepickerAction = BlockAction<DatepickerAction>;

// Relics of the past

// type KnownActionFromElementType<T extends string> = Extract<ElementAction, { type: T }>;
// type ActionFromElementType<T extends string> = KnownActionFromElementType<T> extends never ?
// BasicElementAction<T> : KnownActionFromElementType<T>;
4 changes: 1 addition & 3 deletions src/types/actions/dialog-action.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { StringIndexed } from '../helpers';

/**
* A Slack dialog submit action wrapped in the standard metadata.
*
* This describes the entire JSON-encoded body of a request from Slack dialogs.
*/
export interface DialogSubmitAction extends StringIndexed {
export interface DialogSubmitAction {
type: 'dialog_submission';
callback_id: string;
submission: { [name: string]: string };
Expand Down
4 changes: 1 addition & 3 deletions src/types/actions/interactive-message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { StringIndexed } from '../helpers';

/**
* All actions which Slack delivers from legacy interactive messages. The full body of these actions are represented
* as [[InteractiveMessage]].
Expand Down Expand Up @@ -31,7 +29,7 @@ export interface MenuSelect {
*
* This describes the entire JSON-encoded body of a request from Slack's legacy interactive messages.
*/
export interface InteractiveMessage<Action extends InteractiveAction = InteractiveAction> extends StringIndexed {
export interface InteractiveMessage<Action extends InteractiveAction = InteractiveAction> {
type: 'interactive_message';
callback_id: string;
actions: [Action];
Expand Down
4 changes: 1 addition & 3 deletions src/types/actions/message-action.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { StringIndexed } from '../helpers';

/**
* A Slack message action wrapped in the standard metadata.
*
* This describes the entire JSON-encoded body of a request from Slack message actions.
*/
export interface MessageAction extends StringIndexed {
export interface MessageAction {
type: 'message_action';
callback_id: string;
trigger_id: string;
Expand Down

0 comments on commit 8f9245f

Please sign in to comment.