My goal is to ensure that the "options" property of the parameter object includes the "label" property.
I attempted to achieve this, but encountered compilation errors in my code.
interface BaseOptionType {
label: string;
}
interface CreatableAutoCompleteProps<OptionType extends BaseOptionType> {
name?: string;
options: OptionType;
}
const CreatableAutoComplete = <_OptionType,>({
name,
options,
}: CreatableAutoCompleteProps<_OptionType>): number => {
return 0;
};
export default CreatableAutoComplete;
Upon compiling, I encountered the following error:
(type parameter) _OptionType in <_OptionType>({ name, options, }: CreatableAutoCompleteProps<_OptionType>): number
Type '_OptionType' does not satisfy the constraint 'BaseOptionType'.ts(2344)
What would be the correct approach to address this issue?