158
rated 0 times
[
161]
[
3]
/ answers: 1 / hits: 16859
/ 6 Years ago, tue, november 27, 2018, 12:00:00
Lets say I have an array of key value objects:
const data = [
{key: object1, value: data1},
{key: object2, value: data2},
{key: object3, value: data3},
]
const mappedData = data.map(x => [x.key, x.value]);
const ES6Map = new Map<string, string>(mappedData.values())
How do I convert it to ES 6 map? It works in JavaScript but TypeScript will complain. Here I got the error of Argument of type 'IterableIterator<string[]>' is not assignable to parameter of type 'ReadonlyArray<[string, string]>'.
Property 'length' is missing in type 'IterableIterator<string[]>'.
More From » typescript