I'm completely lost, can someone please help me with this issue:
Currently, I am trying to update a typed configuration.
Within my Provider component:
const [data, setData] = useImmer<typeof INITIAL_CONFIG>(INITIAL_CONFIG)
...
function updateField(field: MyConfigKeys, value: MyConfigValues): void
setData(draft => {
draft[field] = value
})
}
Encountering the following error:
(parameter) draft: WritableDraft<Partial<MyConfigType>>
Type 'MyConfigValues' is not assignable to type 'undefined'.
Type 'string' is not assignable to type 'undefined'.ts(2322)
Can anyone explain what's happening here?
For further reference, you can check out this sandbox with a basic example: https://codesandbox.io/s/exciting-keldysh-kxvckq?file=/src/App.tsx (where the error shows as never instead of undefined)