Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split up View type to improve TS linting #1276

Merged
merged 2 commits into from Aug 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 22 additions & 4 deletions packages/types/src/index.ts
Expand Up @@ -31,20 +31,38 @@ export interface Dialog {
state?: string;
}

export interface View {
title?: PlainTextElement;
type: 'home' | 'modal' | 'workflow_step';
interface HomeView {
type: 'home';
blocks: (KnownBlock | Block)[];
private_metadata?: string;
callback_id?: string;
external_id?: string;
}

interface ModalView {
type: 'modal';
title: PlainTextElement;
blocks: (KnownBlock | Block)[];
close?: PlainTextElement;
submit?: PlainTextElement;
private_metadata?: string;
callback_id?: string;
clear_on_close?: boolean; // defaults to false
notify_on_close?: boolean; // defaults to false
submit_disabled?: boolean; // defaults to false
external_id?: string;
submit_disabled?: boolean; // defaults to false
alexjamesmalcolm marked this conversation as resolved.
Show resolved Hide resolved
}

interface WorkflowStepView {
type: 'workflow_step';
blocks: (KnownBlock | Block)[];
private_metadata?: string;
callback_id?: string;
submit_disabled?: boolean; // defaults to false
}

export type View = HomeView | ModalView | WorkflowStepView;

/*
* Block Elements
*/
Expand Down