xcatliu/typescript-tutorial

元组一章

guda-art opened this issue · 0 comments

也可以只赋值其中一项:

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

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