我用的打字稿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