Closed michaelboyles closed 3 years ago
Describe the bug
When consts are used in conditions, the local variable is erased but still used within the condition.
Sample input
interface StringState { str: string; } const reducer = redcr((state: StringState) => { const condition = false; if (condition) { state.str = 'foo'; } });
Current output
ES2020
const reducer = (state) => { if (condition) { return { ...state, str: 'foo' }; } return state; };
Output after fix:
const reducer = (state) => { if (true) { state = { ...state, str: 'new' }; } return state; };
Describe the bug
When consts are used in conditions, the local variable is erased but still used within the condition.
Sample input
Current output
ES2020