How to turn a string | string[] into string[]
Asserting req.query to a string[] does not change it's true type, all it does it tell TS to treat it like a string[] when doing it's type checking. As such, it can cause errors when not used with a good reason. I have definitely seen people confuse assertions with an actual practical change in object type which it is not.
if you need to ensure your processing code gets an array, then you can say something like
const { investmentIds } = req.query
const idArr = Array.isArray(investmentIds) ? investmentIds : [investmentIds];
then use idArr which we now know is an array.