0

I have some data:

export const defaultStatus = 'AVB'
export const prodStatus = {
   AVB: 'Available',
   DEL: 'Delivered',
   PND: 'Pending',
   NOT: 'Not available'
}

I need to print a value e.g.

The default status is {prodStatus[defaultStatus]}

It gives an error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type

How do I fix it?

Also, not sure how to define type of prodStatus ... prodStatus: string[] gives an error too. I am happy to adapt the data structure of prodStatus if it makes it easier to handle. My main idea is to be able to create a list from this data, allow user to pick one item and then print that value.

Danny
  • 33
  • 6
  • 1
    _"How do I fix it?"_ - [Searching for the error message](https://duckduckgo.com/?q=%22Element+implicitly+has+an+%27any%27+type+because+expression+of+type+%27string%27+can%27t+be+used+to+index+type%22+site%3Astackoverflow.com) would be a good start... [Element implicitly has an 'any' type because expression of type 'string' can't be used to index](https://stackoverflow.com/questions/57086672/element-implicitly-has-an-any-type-because-expression-of-type-string-cant-b) – Andreas Dec 10 '21 at 19:10
  • Yes I think so. I get the idea. I tried searching through documentation and even went through various diff tutorials about retrieving data etc ..but didn't search by the error message. – Danny Dec 10 '21 at 19:13

0 Answers0