与打字稿

与打字稿

问题描述:

创建的属性的任何量的一个接口I具有以下哈希表:与打字稿

{ 
    1: [1, 2, 3, 4], 
    2: [1, 2, 3, 4], 
    ... 
} 

对象密钥是类的数目和阵列具有学生的数量。

如何定义键的接口?

// pseudo code 
interface ClassStudentRelationshipInterface { 
    {any amount of keys should be a number}: number[]; 
} 

谢谢。

您可以用number类型的关键接口指定index signature

interface ClassStudentRelationshipInterface { 
    [key: number]: number[]; 
}