Typescript Array Object Is Possibly Undefined Typescript Vs Javascript