From 9e54d2b0a9dcd77d84cc612ba8cfc414a8b17d52 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 5 Nov 2022 08:29:43 +0100 Subject: [PATCH] fix: broken types --- packages/form/core/form-control.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/form/core/form-control.ts b/packages/form/core/form-control.ts index 7c3da13..9c2f930 100644 --- a/packages/form/core/form-control.ts +++ b/packages/form/core/form-control.ts @@ -2,16 +2,16 @@ import type { Button, Checkbox, ControlType, - TextInput, Radio, Dropdown, ControlOption, Submit, ValidationError, TextArea, + ControlBase, } from '@astro-reactive/common'; -export type ControlConfig = TextInput | Checkbox | Radio | Submit | Button | Dropdown | TextArea; +export type ControlConfig = ControlBase | Checkbox | Radio | Submit | Button | Dropdown | TextArea; export class FormControl { private _name = ''; @@ -44,7 +44,6 @@ export class FormControl { label = '', placeholder = null, validators = [], - options = [], } = config; this._name = name; @@ -53,10 +52,14 @@ export class FormControl { this._label = label; this._placeholder = placeholder; this._validators = validators; - this._options = options; + + if (type === 'radio' || type === 'dropdown') { + const { options = [] } = config as Radio | Dropdown; + this._options = options; + } if (config.type === 'textarea') { - const { rows = null, cols = null } = config; + const { rows = null, cols = null } = config as TextArea; this._rows = rows; this._cols = cols; }