What makes the code below invalid in strict mode?
let x: string[];
if (Math.random() > .5){ x = ['x']; }
//TS2454: x possible undefined. Yeah, I know?
return x?.map(v => v);
Yes, it is acknowledged that x
could potentially be undefined. However, this is why the Optional Chaining Operator is being utilized. It effectively handles cases where a variable may be undefined.