import type { OptionsType, OptionType, SectionOptionType } from './types'; export type OptionalToRequired = { [P in keyof Required]: Pick extends Required> ? T[P] : T[P] | undefined; }; export const isFlatOptionsType = (val: OptionsType): val is OptionType[] => val.length > 0 && 'label' in val[0] && 'value' in val[0]; export const isSectionOptionsType = (val: OptionsType): val is SectionOptionType[] => val.length > 0 && 'title' in val[0] && 'data' in val[0]; export const isOptionType = (val: OptionType | OptionType[]): val is OptionType => 'label' in val && 'value' in val; export const isOptionIndexType = (val: number | number[]): val is number => typeof val === 'number';