是否可以在Typescript中添加描述到数组类型?



我有以下类型:

const type Person = [string, number, number]

const type Person = [
string, // name
number, // age
number // height
]

可以给元素添加注释吗?或者有什么惯例吗?和function一样:TypeScript注释的语法文档在哪里?

我认为最接近的解决方案是标签元组元素

const type Person = [name: string, age: number, height: number]

最新更新