Open t1nky opened 1 year ago
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>;
Do you think it is possible to use conditional types?