0

I'm new to typescript, my Objective is to get the object and represent in UI, but i'm getting the object as

{
name: "ABC",
age: 5
}

I'm getting error in this way ***Property 'name' does not exist on type 'object'*** 

Can anyone please help me in this query?

1 Answer 1

3

You will need to be more specific in defining types.

interface State {
  data: {
    name: string;
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, if i have 4 different objects with same property then how could we assign for them. Do we need to assign like this for 4 objects? if no then please assist me
Yes, or you can define a parent interface and inherit it from others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.