typescript-tutorial icon indicating copy to clipboard operation
typescript-tutorial copied to clipboard

元组一章节描述有误

Open xyx650 opened this issue 4 years ago • 0 comments

章节地址 https://ts.xcatliu.com/advanced/tuple#jian-dan-de-li-zi

当赋值或访问一个已知索引的元素时,会得到正确的类型: let tom: [string, number]; tom[0] = 'Tom'; tom[1] = 25; tom[0].slice(1); tom[1].toFixed(2);

也可以只赋值其中一项: let tom: [string, number]; tom[0] = 'Tom';

示例代码报错,查询ts官网和其他网站,并没有发现这种写法,只能整个数组一起赋值 let tom: [string, number]; tom = ['Tom', 22 ]

xyx650 avatar May 21 '20 08:05 xyx650