From 71ed501f0782c0d9f90d7f329c9dba0c3d45bb08 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 26 Mar 2021 13:40:02 +0300 Subject: [PATCH] Specifying types a bit more Signed-off-by: Alex Andreev --- src/renderer/components/select/select.tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/renderer/components/select/select.tsx b/src/renderer/components/select/select.tsx index 7ae1dcbde5..92516d2cd6 100644 --- a/src/renderer/components/select/select.tsx +++ b/src/renderer/components/select/select.tsx @@ -12,18 +12,21 @@ import { themeStore } from "../../theme.store"; const { Menu } = components; +type OptionType = { label: string; value: string }; +type GroupType = GroupTypeBase; + export interface GroupSelectOption { label: ReactNode; options: T[]; } export interface SelectOption { - value: T; + value?: T; label?: React.ReactNode; } -export interface SelectProps extends ReactSelectProps> { - options?: readonly any[]; +export interface SelectProps extends ReactSelectProps { + options?: ReadonlyArray; value?: T; themeName?: "dark" | "light" | "outlined"; menuClass?: string; @@ -70,15 +73,9 @@ export class Select extends React.Component { } @computed get options(): readonly SelectOption[] { - const { autoConvertOptions, options } = this.props; - - if (autoConvertOptions && Array.isArray(options)) { - return options.map(opt => { - return this.isValidOption(opt) ? opt : { value: opt, label: String(opt) }; - }); - } - - return options; + return this.props.options.map(opt => { + return this.isValidOption(opt) ? opt : { value: opt, label: String(opt) }; + }); } @autobind()