Skip to content

Instantly share code, notes, and snippets.

@taras
Created April 30, 2019 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taras/661f8abbd2bcb53a2ce76ac946242927 to your computer and use it in GitHub Desktop.
Save taras/661f8abbd2bcb53a2ce76ac946242927 to your computer and use it in GitHub Desktop.
type ID = string | number;
interface Field {
name: string;
id: ID;
required?: boolean;
}
interface TextField extends Field {
type: "Text";
}
interface SelectField<T = string | number> extends Field {
type: "Select"
options: Option<T>
default?: string
required?: boolean;
}
interface StepperField extends Field {
type: "Stepper"
default?: number;
min?: number;
max?: number;
disabledValue: number | undefined;
}
type Option<T> = {
value: T;
label: string;
}
export type Fields = TextField | SelectField | StepperField;
export type FieldType = Fields["type"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment