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

元组一章

Open guda-art opened this issue 3 years ago • 0 comments
trafficstars

也可以只赋值其中一项:

let tom: [string, number];
tom[0] = 'Tom';

编译时不报错, 也能通过类型检查, 但是tom[0]是undefined,, 所以运行时会报错 ts-node .ts或node .js都会报错

guda-art avatar Oct 11 '22 06:10 guda-art