
上QQ阅读APP看书,第一时间看更新
Array type interfaces
We can also define an interface for array types. We can specify the data type for the index array and the data type to the array item as follows:
interface CutomerNameArray { [index: number]: string; } var customerNameList: CutomerNameArray; customerNameList = ["Rajesh", "Gunasundaram"];
TypeScript supports two types of index: number and string. This array type interface also stipulates that the return type of the array should match the declaration.