I was looking through angular2 code and saw a few things such as:
this._outlets[name] = undefined !;
What is the meaning of that !
at the end? Couldn't find anything on google about it :(
I was looking through angular2 code and saw a few things such as:
this._outlets[name] = undefined !;
What is the meaning of that !
at the end? Couldn't find anything on google about it :(
After some checking I found out that it is indeed telling the compiler that undefined is not undefined
:)
In case you run the compiler with --strictNullChecks
trying to assign undefined to something such as a string for example will yielf in the following error: Type "undefined" is not assignable to type "string"
. If you use undefined !
you basically bypass this check and tsc won't give you an error for it.
This post-fix expression operator ! may be used to assert that its operand cannot be null or undefined during runtime.