#Is it possible to represent this data using TS Interfaces?

4 messages · Page 1 of 1 (latest)

toxic sinew
#

Is it possible in TS to use types the following data structure??

{
  "productCount": {
    "product1": 9,
    "product2": 1,
    "product3": 10
  }
}

the key will be ALWAYS a string and the value will be ALWAYS a number

tribal arch
#

Your whole object would be typed as

type Something = {
  productCount: Record<string, number>
}
toxic sinew
#

perfect! thank you sir!