score:0
i only need to say to typescript that the object can access a [key: string]: value: any on the iresponse interface!
like:
interface iresponse {
[key: string]: your-value-type
[...]
}
score:2
i see 2 different issues here. first you have to call print values return <ul>{printvalues()}</ul>
. second you are not handling when person.data is empty on the first render before the data is fetched.
update after comment: alright since you have these the actual way to fix the type error is like this
let key: keyof iresponse['data'];
for (key in person.data) {
the issue is you do not have any string type keys. so you need to say you are using the keys of that object
if you dont like that syntax you can always use the following instead
for (let [key, value] in object.entries(person.data))
Source: stackoverflow.com
Related Query
- TypeScript | Can't loop over a custom type Object
- Typescript how to type custom key in an object
- Functional custom component in an object loop with typescript
- type of custom object in typescript
- What TypeScript type should I use to reference the match object in my props?
- ES2015 module syntax is preferred over custom TypeScript modules and namespaces @typescript-eslint/no-namespace
- Javascript / webpack : how to concatenate all json files in directory with a custom loop over files
- Make id in FormattedMessage from react-intl inherit from a custom TypeScript interface to enable VS IntelliSense and type checking
- React Custom Hook with Typescript Type error "Property 'x' does not exist on type 'interface | (({ target }: any) => void)'.ts(2339)"
- React / Typescript : pushing obj into array of object and undefined type
- TypeScript type for value of key in object
- typescript failed to infer destructuring array type in custom hook
- Typescript - infer generic type from object prop value
- Mapping data object with a type field to specific React Components with TypeScript
- React Typescript Custom Hooks: Property 'prop_name' does not exist on type '{}'
- Object or Boolean how to declare type in Typescript
- How to properly type a custom selector function, which picks properties from an object
- Don't understand TypeScript function signature with weird object type as param
- Autocomplete in return type Typescript based on input object
- Typescript generic type for nested object properties
- Redux thunk - Error ยท Actions must be plain objects. Use custom middleware for async actions even with dispatch an object with key type
- Custom React Hook typescript error on array return type
- Adding custom Typescript type declaration for a node module in Create React App
- How to type custom hook useStateWithCallback React TypeScript
- How to correctly type a null value in typescript react app, retrieved from an JSON object (api call) when using Object.entries to retrieve the value?
- Loop over state and check if object exists
- object parameters type definition in typescript
- typescript custom hook ,event type question
- Object is of type unknown error when using Typescript with React
- Cant access object value returned from axios in custom hooks
More Query from same tag
- @tailwindcss/forms plugin not working with React
- How to use react-select-async-paginate library on change of different select?
- Converting multiple configuration routes in react-router's plain objects
- I had to graph income and expenses, wanting only the current year to graph. React sequelize
- Defining a javascript class Method as a constant
- How to focus input on a child component from parent?
- React Context API & HOC
- Is CORS error specific to the nginx server or should I add something to my code
- Type '{}' is not assignable to type 'IntrinsicAttributes & DropdownProps & Props &
- Component won't update
- Reactjs rerender component after CRUD Operation
- How to toggle a radio button in Typescript React?
- Legend in Linechart- google-charts-react
- React | Multiple render
- Getting an object instead of a boolean value
- Unable to Fetch backend from frontend
- React Ag grid expandAll in enterprise
- How to fetch data from API using id in reactJS?
- Background Image not showing on build React
- React event handling together with plain JS
- react + typescript How to fix props type error
- How to remove last divider from the list in Grid system in Material Ui
- Warning: isMounted(...) is deprecated in plain Javascript Classes
- react js increment count existing object in array
- React component is changing an uncontrolled input of type checkbox
- How to send a handleSubmit on react hook form in typescript?
- Redux how to handle errors in reducer
- How to print react select state in another component?
- React Function Component Form not setting state variables?
- How do I style a div inside a component without passing props to that component (I'm using a package)