I am building a form with dynamic fields and I am trying to get over a TS error that says a type string is not assignable to type never.
<Controller
control={control}
name={`${category}` as const}
render={({ field: { value, onChange } }) => (
<Stack gap={1.5}>
{filterObj?.[category as keyof typeof filterObj]?.map((item) => (
<Checkbox
onChange={() => {
onChange(value ? [...value, item] : [value].filter((v) => v !== item))
}}
checked={value?.includes(item)} <-- throws an error
label={item}
key={item}
/>
))}
</Stack>
)}
/>
The line where i am checking to if the value is checked is throwing the error
Property 'includes' does not exist on type 'never'.
I tested item: any on the map function, but then it says type any is not assignable to never. I am not sure what I am missing here. Any hints?