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

当赋值或访问一个已知索引的元素时,会得到正确的类型

Open jianjiachenghub opened this issue 5 years ago • 0 comments

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

jianjiachenghub avatar Dec 12 '19 07:12 jianjiachenghub