非空断言操作符、可选链运算符、空值合并运算符
非空断言操作符
https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#non-null-assertion-operator
作用:排除掉变量中的 null
和 undefeind
使用:a!
示例:
function simpleExample(a: number | undefined) {
const b: number = a; // COMPILATION ERROR: undefined is not assignable to number.
const c: number = a!; // OK
}