0

I have just come across

this.person!.name

in my codebase, previously I have seen this.person?.name which is optional chaining, but I have never seen ! be used nor can I find any resource to explain it's use, can anyone shed any light on it?

2
  • 1
    It means that according to Typescript, this.person can be null or undefined, but the developer who coded this know that in this specific case, the value can't be null or undefined, so he added ! to remove the warning about nullability Commented Nov 3, 2022 at 15:52
  • It's slightly worrying that you tagged this typescript code in your codebase as javascript. Commented Nov 3, 2022 at 15:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.