When using Lodash's _.reduce()
with an object, I encountered a TypeScript error (as shown below) that indicates it expects an array instead. How can I resolve the type mismatch in this scenario?
interface Fees {
CardHandlingFee: number;
AirlineSurcharge: number;
}
const fees: Fees = {
CardHandlingFee: 2,
AirlineSurcharge: 3
};
let total = 100;
// Argument of type 'Fees' is not assignable to parameter of type 'NumericDictionary'.
// Index signature is missing in type 'Fees'.
total += _.reduce(fees, (sum: number, v: number) => sum + v, 0);