我用的打字稿1.7.5和我遇到以下情况An index expression argument must be of type 'string', 'number', or 'any'
错误:打字稿 - 索引表达式参数的类型必须是“字符串”,“数字”,“符号”或“任意”
const settings: any = {};
_.forEach(data, (d, name: string) => { //data is just an object
settings[name] = {};
const colors = ColorGenerator.generateColors(Object.keys(d.ch).length);
_(d.ch)
.keys()
.zip(colors)
.forEach(([channel, color]) => {
// name and channel are both strings
settings[name][channel] = { // this line is throwing the error
channel,
color,
visible: true
};
}).value();
});
是否是导致错误的channel
变量?我怎样才能在同一时间输入并解构它?
P.S.我已经省略了不必要的代码,所以如果有什么不合理的话让我知道。
的索引/键通道和颜色为什么是U将数组传递给'forEach'? – giannisf
你的意思是?第二个'forEach'? – XeniaSis