简体   繁体   English

如何在 typescript 中输入 object 的 object

[英]how to type for object of object in typescript

How to type for following data.如何键入以下数据。 I have to type for progress object我必须输入进度 object

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

There is built-in type - Record<K, V>有内置类型 - Record<K, V>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM