typescript-tutorial
typescript-tutorial copied to clipboard
元组一章
trafficstars
也可以只赋值其中一项:
let tom: [string, number];
tom[0] = 'Tom';
编译时不报错, 也能通过类型检查, 但是tom[0]是undefined,, 所以运行时会报错 ts-node .ts或node .js都会报错