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

225
Views
React typescript error: Element implicitly has an 'any' type

I am a beginner at typescript and I am using it in reactjs but I am getting errors. Could someone please help me with how to resolve this issue? Element implicitly has an 'any' type because expression of type 'string' can't be used to index type.

export const colors = {
  RootBackground: "#fff",
}



style = {
  [
    buttonStyle ? buttonStyle : styles.button,
    {
      backgroundColor: colors[color],
      width
    },
  ]
}

Note: Error is on this line colors[color]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Limit color to be a key of colors:

interface Props {
  color: keyof typeof colors
  // other props
}
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!