我有一个场景,在C#中,
decimal? x; // number
decimal? y; // null
c=x*y //c returns null
Run Code Online (Sandbox Code Playgroud)
打字稿中的位置
let x:number=null;
let y:number=12;
c=x*y //c returns 0
Run Code Online (Sandbox Code Playgroud)
**如何在打字稿中获取null而不是0?
我需要设置泛型方式而不是使用三元运算符并检查属性null并返回null.
我需要在tsconfig.json中设置任何编译器选项吗?**