The non-null assertion operator tells the TypeScript compiler that a value typed as optional cannot be null or undefined. For example, if we define a variable as possibly a string or undefined, the ! operator tells TypeScript to ignore the possibility of it being undefined. We will be using these terms interchangeably in this article.

8m read timeFrom blog.logrocket.com
Post cover image
Table of contents
What is the TypeScript exclamation mark?What the exclamation mark does in TypeScriptWe made a custom demo for . No really. Click here to check it out .Popular use cases for the TypeScript exclamation markThe downside of using the exclamation mark in TypeScriptAlternatives to using the TypeScript exclamation markConclusionWriting a lot of TypeScript? Watch the recording of our recent TypeScript meetup to learn about writing more readable code.

Sort: