there is an obvious type missmatch and it can possible be a developer's error.
There's nothing obviously wrong with this code. Consider something like this:
let items = [1, 2, 3];
// Print each item in the array
items.forEach(item => console.log(item));
Is this code correct? Definitely! But forEach
invokes its provided function with three arguments, not one. It would be tedious to have to write:
items.forEach((item, unused1, unused2) => console.log(item));
Note that you can still get errors if you try to do something that's actually wrong. For example:
function printNumber(x: number) { console.log(x); }
let strings = ['hello', 'world'];
strings.forEach(printNumber); // Error, can't convert string to number
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…