Skip to content

Commit

Permalink
simplify an options type, TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Maj committed Sep 19, 2024
1 parent cbfa00c commit cc1a6b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/types/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ export interface SlackOptionsMiddlewareArgs<Source extends OptionsSource = Optio
ack: OptionsAckFn<Source>;
}

export type SlackOptions = BlockSuggestion | InteractiveMessageSuggestion | DialogSuggestion;

// TODO: why call this 'source'? shouldn't it be Type, since it is just the type value?
/**
* All sources from which Slack sends options requests.
*/
export type OptionsSource = 'interactive_message' | 'dialog_suggestion' | 'block_suggestion';

export type SlackOptions = BlockSuggestion | InteractiveMessageSuggestion | DialogSuggestion;
export type OptionsSource = SlackOptions['type'];

export interface BasicOptionsPayload<Type extends string = string> {
type: Type;
value: string;
}

// TODO: Is this useful? Events have something similar
export type OptionsPayloadFromType<T extends string> = KnownOptionsPayloadFromType<T> extends never
? BasicOptionsPayload<T>
: KnownOptionsPayloadFromType<T>;
Expand Down Expand Up @@ -145,8 +147,8 @@ export interface DialogSuggestion extends StringIndexed {
type OptionsAckFn<Source extends OptionsSource> = Source extends 'block_suggestion'
? AckFn<XOR<BlockOptions, OptionGroups<BlockOptions>>>
: Source extends 'interactive_message'
? AckFn<XOR<MessageOptions, OptionGroups<MessageOptions>>>
: AckFn<XOR<DialogOptions, DialogOptionGroups<DialogOptions>>>;
? AckFn<XOR<MessageOptions, OptionGroups<MessageOptions>>>
: AckFn<XOR<DialogOptions, DialogOptionGroups<DialogOptions>>>;

// TODO: why are the next two interfaces identical?
export interface BlockOptions {
Expand Down

0 comments on commit cc1a6b4

Please sign in to comment.