How to solve ”variable is possibly undefined” in TypeScript - even when it’s defined

Learn how to solve the "variable is possibly undefined" error in TypeScript and avoid nesting with ternary operators in React