After updating Immer to version 1.10.4. I'm running into a couple of typing errors on typescript.
example code:
import produce from 'immer'
export interface ConditionHandlerOutput {
readonly errorMsg: string[],
readonly success: boolean,
}
const stateList: ConditionHandlerOutput[] = []
// `x` cannot be modified here
const state: ConditionHandlerOutput = {
errorMsg: [],
success: true,
}
const newState = produce(state, draft => {
// `x` can be modified here
draft.errorMsg.push('This is a random string')
draft.success = false
})
stateList.push(newState)
Expected behaviour: newState has type: ConditionHandlerOutput
Observed behavior: newState hasn't the expected type and given type is not comparable. Returned typ is:
const newState: {
readonly errorMsg: ReadonlyArray<string>;
readonly success: boolean;
}
After updating Immer to version 1.10.4. I'm running into a couple of typing errors on typescript.
example code:
Expected behaviour:
newStatehas type:ConditionHandlerOutputObserved behavior:
newStatehasn't the expected type and given type is not comparable. Returned typ is: