如何在打字稿中定义数组类型?

时间:2017-01-26 10:26:15

标签: arrays typescript

我在打字稿中使用以下类型的变量:

[[string, string], string][]

有没有办法将其定义为类型,所以我不必在代码中的任何地方重复此定义?

1 个答案:

答案 0 :(得分:4)

您可以定义type

type stringTuple = [[string, string], string][];

然后使用它类似于使用类或接口的方式:

var array: stringTuple;