【发布时间】:2020-06-13 03:50:30
【问题描述】:
根据MDN doc
像这样从数组初始化 Map 是合法的:
let kvArray = [['key1', 'value1'], ['key2', 'value2']];
let myMap: Map<string, string> = new Map(kvArray);
尽管如此,我的 Visual Studio Code 编译器还是抱怨:
No overload matches this call.
Overload 1 of 3, '(iterable: Iterable<readonly [string, string]>): Map<string, string>', gave the following error.
Argument of type 'string[][]' is not assignable to parameter of type 'Iterable<readonly [string, string]>'.
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
【问题讨论】:
标签: arrays typescript dictionary