Typescript Object Is Possibly Undefined After Check