3

e.g. a += b! - c!; I saw several expressions like this but I can't find what it's called or what it does

  • 1
    It’s the [non-null assertion operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator) – Linda Paiste May 26 '21 at 14:18

1 Answers1

4

you're telling the compiler that even though judging purely by the code, the variable could be undefined, you, the programmer, know for 100% sure that it will have a value, so you're not going to do a check to see if it has a value or not.

See playground example

Bart van den Burg
  • 2,166
  • 4
  • 25
  • 42