错误 TS2345:'Map<String, boolean>' 类型的参数不可分配给 'IterableShim<[String, boolean]>' 类型的参数
error TS2345: Argument of type 'Map<String, boolean>' is not ass ignable to parameter of type 'IterableShim<[String, boolean]>'
我有以下打字稿代码片段:
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-shim 类型描述的类型 (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/es6-shim)。
非常感谢,
托比亚斯
我是通过调用map的"entries()"
方法解决的。这提供了 Map 构造函数等待的可迭代对象。
setSelection(selection: Map<String, boolean>) {
this.selection = new Map<String, boolean>(selection.entries());
}
我有以下打字稿代码片段:
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-shim 类型描述的类型 (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/es6-shim)。
非常感谢,
托比亚斯
我是通过调用map的"entries()"
方法解决的。这提供了 Map 构造函数等待的可迭代对象。
setSelection(selection: Map<String, boolean>) {
this.selection = new Map<String, boolean>(selection.entries());
}