Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Property 'name' does not exist on type 'object' TypeScript

I have this array.map function:

{props.help.map((e, i) => {
return <a key={i}>{e.name}</a>
})}

{e} object have ‘name’ and ‘href’ keys

i got "Property ‘name’ does not exist on type ‘object’" (typescript)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am beginner in typescript.

>Solution :

Create an interface for a Help object, and use it in the definition of your props:

interface Help {
  name: string;
  // other properties
}

interface Props {
  help: Help[];
}

And then use Props when defining the component:

const Component = (props: Props) => {
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading