Typescript exclamation parentheses

Viewed 445

I've come across this statement on the angular website:

this.resolve !('hi there!');

I have no idea what the ! might mean in this context. I've come across the non-null assertion operator but I somehow don't think that's what it is here. Any idea?

1 Answers

It is the non-null assertion operator. Note that the type for this.resolve is Function|null so it can possibly be null.

It is added so that the compiler stops complaining about this.resolve being possibly null with strictNullChecks compiler option turned on.

Related