michaelboyles / redcr

Compile-time alternative to Immer
MIT License
6 stars 0 forks source link

[FEATURE] Support switch statements #4

Closed michaelboyles closed 3 years ago

michaelboyles commented 3 years ago

Example:

interface StringState {
    str: string;
}

const foo: number = 3;

const reducer = redcr((state: StringState) => {
    switch (foo) {
        case 1: 
            state.str = 'one';
            break;
        case 2:
            state.str = 'two';
            break;
        default:
            state.str = 'other';
    }
});