打字稿感叹号括号

Ren*_*aud 5 typescript angular

在 angular 网站上遇到过这个声明:

this.resolve !('hi there!');
Run Code Online (Sandbox Code Playgroud)

我不知道!在这种情况下可能意味着什么。我遇到过非空断言运算符,但不知何故我不认为这就是它的含义。任何的想法?

Sar*_*ana 3

是非空断言运算符。this.resolve请注意, for的类型Function|null因此可能为 null。

添加它是为了让编译器停止抱怨在this.resolve打开编译器选项的情况下可能为空strictNullChecks