I'm using Typescript ~2.4 if it matters.
I have a variable that is cast as {} | {}[] | string[]. I do a check when it's an array, and want to iterate over it. I figured a forEach is best on that:
(<{}[] | string[]>data).forEach((val) => {
this.options.push(setupValue(val));
});
But it says Cannot invoke an expression whose type lacks a call signature. I can't see where I went wrong. I can't tell if this is a problem with how I'm using Typescript or my own logic?
(<{}[]>data).forEachand(<string[]>data).forEachare fine.