I've seen in some React/TypeScript implementations such as :
ref={ ref => this.container = ref! }
What does the exclamation point means in ref!
?
Is that something specific in TypeScript, or a new standard JavaScript notation?
I've seen in some React/TypeScript implementations such as :
ref={ ref => this.container = ref! }
What does the exclamation point means in ref!
?
Is that something specific in TypeScript, or a new standard JavaScript notation?
In TypeScript, a postfix !
removes null
and undefined
from the type of an expression.
This is useful when you know, for reasons outside TypeScript's inference ability, that a variable that "could" be null
or undefined
actually isn't.