Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
typeof object of array of object in typescript?

How do I replace any below with options's object shape below?

interface selectComponentProps {
  options: {
    label: string;
    value: string;
  }[];
}

const SelectComponent: React.FC<selectComponentProps> = ({
   options,
}) => {
  const handleChange = (selectedOption: any) => { //here
    
  };

  return (
    <Select
      options={options}
    />
  );
};
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can extract the model for a single option to a separate interface:

interface selectComponentProps {
  options: selectComponentPropsOption[];
}

interface selectComponentPropsOption {
  label: string;
  value: string;
}

Then you can replace any with selectComponentPropsOption.

about 4 years ago · Juan Pablo Isaza Report

0

Option 1.

const handleChange = (selectedOption: typeof options[0]) => { //here
    
};

Option 2.

interface Option {
  label: string;
  value: string;
}
interface selectComponentProps {
  options: Option[];
}
const handleChange = (selectedOption: Option) => { //here
    
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!