While attempting to generate a Map, I encounter an unfamiliar error message that is puzzling:
TS2769: No overload matches this call.
Overload 1 of 4, '(iterable: Iterable<readonly [string, number]>): Map<string, number>', gave the following error.
Argument of type '(string | number)[][]' is not assignable to parameter of type 'Iterable<readonly [string, number]>'.
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
Type 'IteratorResult<(string | number)[], any>' is not assignable to type 'IteratorResult<readonly [string, number], any>'.
In my programming code, I am taking in an array and attempting to form a map object out of it
function createMapOfHeadersToIndex(headers: string[]): Map<string, number> {
const headersWithIndex =
headers.map(header => [header, Number(headers.indexOf(header))]);
return new Map(headersWithIndex);
}