📜  在 typescript 中,语句末尾的 bang 是什么意思 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:12.683000             🧑  作者: Mango

代码示例1
function simpleExample(nullableArg: number | undefined | null) {
   const normal: number = nullableArg; 
    //   Compile err: 
    //   Type 'number | null | undefined' is not assignable to type 'number'.
    //   Type 'undefined' is not assignable to type 'number'.(2322)

   const operatorApplied: number = nullableArg!; 
    // compiles fine because we tell compiler that null | undefined are excluded 
}