-1

我有以下打字稿代码片断:错误TS2345:类型的参数“地图<字符串,布尔>”未屁股ignable到类型的参数“IterableShim <[字符串,布尔]>”

setSelection(selection: Map<String, boolean>) { 
     this.selection = new Map<String, boolean>(selection); 
} 

但这给了我以下错误:

error TS2345: Argument of type 'Map' is not ass ignable to parameter of type 'IterableShim<[String, boolean]>'. Property '"es6-shim iterator"' is missing in type 'Map'.

我做错了什么(代码工作虽然)?

我使用与ES6-垫片类型描述(https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/es6-shim)分型。

非常感谢,

托比亚斯

回答

0

我通过调用地图的"entries()"方法解决它。这提供了Map构造函数等待的迭代。

setSelection(selection: Map<String, boolean>) { 
    this.selection = new Map<String, boolean>(selection.entries()); 
} 
相关问题