如何在打字稿中定义数组类型? [英] How to define array type in typescript?
本文介绍了如何在打字稿中定义数组类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在打字稿中使用以下类型的变量:
I am using variables of the following type in typescript:
[[string, string], string][]
是否可以将其定义为类型,所以我不必在所有地方重复此定义代码?
Is there a way to define this as type so I don't have to repeat this definition everywhere in my code?
推荐答案
您可以定义类型
:
type stringTuple = [[string, string], string][];
然后像使用类或接口一样使用它:
And then later use it similar to how you would use a class or interface:
var array: stringTuple;
这篇关于如何在打字稿中定义数组类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文