- I make a array of tuple
- Then convert it to object with
Object.fromEntries
- Then I would assign to a
<{ [formFieldId: string]: number }>
type.
What is wrong here?
const [itemsWithSelection, setItemsWithSelection] = useState<{ [formFieldId: string]: number }>(itemsWithSelection2)
if (!itemsWithSelection2) {
let aa = Object.keys(invoiceItems).forEach((key) =>
[key, 1]
)
setItemsWithSelection(Object.fromEntries(aa))
}
and got this error:
./components/product/InvoiceItemsToDeliver.tsx:30:44
Type error: No overload matches this call.
Overload 1 of 2, '(entries: Iterable<readonly [PropertyKey, number]>): { [k: string]: number; }', gave the following error.
Argument of type 'void' is not assignable to parameter of type 'Iterable<readonly [PropertyKey, number]>'.
Overload 2 of 2, '(entries: Iterable<readonly any[]>): any', gave the following error.
Argument of type 'void' is not assignable to parameter of type 'Iterable<readonly any[]>'.
28 | [key, 1]
29 | )
> 30 | setItemsWithSelection(Object.fromEntries(aa))
| ^
31 | }