Home > Blockchain >  how to type for object of object in typescript
how to type for object of object in typescript

Time:10-09

How to type for following data. I have to type for progress object

const progress = {
   "1": {
      topic: [1,3,4],
      assessment: [1,2,4,],
   },
   "2": {
      topic: [1,3,4],
      assessment: [1,2,4,],
   },
   ....
}

CodePudding user response:

There is built-in type - Record<K, V>

type Obj = Record<string, {topic: number[], assessment: number[]}>
  • Related