Object is possibly ‘undefined’
Ok, it looks like the culprit here is the use of
"strictNullChecks": true. in your config file.
However I would not recommend removing this flag, this check is actually giving you a valid hint so that can use a better null check in your code. Instead, I would look into better ways to doing the null or undefined check.
There are other two ways to that I can think of to get rid of the error.
The first way I can think of is to use a fallback with the
The other way is to save the value to a variable and check the new variable.