我正在开发一个Angular应用程序,我有以下代码:
// ...
this.x = y ?? z;
// ...
当我运行ng serve
时,我的终端会出现以下错误:
error TS1109: Expression expected.
error TS1005: ':' expected.
Module parse failed: Unexpected token (47:40)
You may need an appropriate loader to handle this file type.
| // ...
| this.x = y ? ? z : : ;
| // ...
为什么要把零的coallesce(y ?? z
)转换成三元的(y ? ? z : :
)?
我试着在nullish coallesce周围添加方括号,但它并没有改变输出.