This source code showcases the usage of @Input
properties with an exclamation mark (!
) at the end. An example is shown below:
@Input() token!: StripeToken
The presence of !
in this case signifies a non-null assertion operator, but what is the significance or lack thereof in this specific scenario?
It could be argued that using the non-null assertion at the end of Angular's @Input
properties might not be practical. What are your thoughts on this?
Update
Upon testing in a new Angular project, an error was encountered:
A definite assignment assertion '!' is not permitted in this context.ts(1255)
Based on this issue, it seems that including the !
operator on an @Input
property may not be advisable. Refer to the screenshot for more information: