¿Cómo reemplazo any de los siguientes con la forma options's continuación?
interface selectComponentProps { options: { label: string; value: string; }[]; } const SelectComponent: React.FC<selectComponentProps> = ({ options, }) => { const handleChange = (selectedOption: any) => { //here }; return ( <Select options={options} /> ); };Puede extraer el modelo para una sola opción a una interfaz separada:
interface selectComponentProps { options: selectComponentPropsOption[]; } interface selectComponentPropsOption { label: string; value: string; } Luego puede reemplazar any con selectComponentPropsOption .
Opción 1.
const handleChange = (selectedOption: typeof options[0]) => { //here };Opcion 2.
interface Option { label: string; value: string; } interface selectComponentProps { options: Option[]; } const handleChange = (selectedOption: Option) => { //here };