Created
April 30, 2019 20:15
-
-
Save taras/661f8abbd2bcb53a2ce76ac946242927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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