TypeScript 4.0·续1
obj.prop = obj.prop || foo();
console.log(“This one sometimes runs the setter”); obj.prop ||= foo();
非常感谢社区成员[Wenlu Wang](https://github.com/Kingwl)为该功能的付出!更多详情请参考[PR](https://github.com/microsoft/TypeScript/pull/37727).你还可以[查看该特性的TC39提案](https://github.com/tc39/proposal-logical-assignment/).## `catch`语句中的`unknown`类型在TypeScript的早期版本中,`catch`语句中的捕获变量总为`any`类型。这意味着你可以在捕获变量上执行任意的操作。```ts twoslashtry { // Do some work} catch (x) { // x 类型为 'any' console.log(x.message); console.log(x.toUpperCase()); x++; x.yadda.yadda.yadda();}
