typescript-tutorial
typescript-tutorial copied to clipboard
当赋值或访问一个已知索引的元素时,会得到正确的类型
let tom: [string, number];
tom[0] = 'Tom';
tom[1] = 25;
tom[0].slice(1);
tom[1].toFixed(2);
TSError: ⨯ Unable to compile TypeScript: tom is used before being assigned