react-tailwindcss-select
react-tailwindcss-select copied to clipboard
Improve types
Do you think it is possible to use conditional types?
interface Option {
value: string;
label: string;
disabled?: boolean;
isSelected?: boolean;
}
type SelectValueType<multiple> = multiple extends true
? null | Option[]
: null | Option;
type SelectValueUnion = SelectValueType<true> | SelectValueType<false>;
interface SelectPropsType<T extends boolean> {
multiple: T;
value: SelectValueType<T>;
onChange: (value: SelectValueType<T>) => void;
}
type SelectProps = SelectPropsType<true> | SelectPropsType<false>;