final-form / final-form-calculate

Decorator for calculating field values based on other field values in 🏁 Final Form
MIT License
113 stars 26 forks source link

calculate sum of total price #43

Closed BakriSusanto closed 4 years ago

BakriSusanto commented 4 years ago

Need help. I got compiler error, want to calculate sum of array field using typescript.

Property 'items' does not exist on type 'Object'. TS2339

                   field: /items\[\d+\].totalPrice/,
151 |           updates:  {
152 |             total: (ignoredValue, allValues) =>

153 | (allValues!.items || []) | ^ 154 | .reduce((sum: any, value: any) => sum + Number(value || 0), 0)