typescript, Array.prototype.map() has error 'expression is not callable' when the callee array is union with empty array
As of December 2020 there is an open issue about this: https://github.com/microsoft/TypeScript/issues/36390
It probably won't get fixed for a little while (Until TypeScript 4.2 or later).
In the mean time you can add as any[]
to get rid of error:
const arr: number[] | string[] = [];
// Add as any[]
(arr as any[]).map((a: number | string, index: number) => {
return index
});