Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Return statement at end of a reducer returns in undefined state #14

Closed
michaelboyles opened this issue Nov 6, 2021 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@michaelboyles
Copy link
Owner

Describe the bug

When return; is added to the end of a block, intuitively you should expect it to make no difference to behaviour. However, in a redcr reducer, it results in the reducer returning undefined.

I can't think of a reason anyone would sensibly do this (in fact, maybe eslint would remove it?) but it low-hanging fruit so worth fixing anyway.

Sample input

interface State {
    str: string;
}
const reducer = redcr((state: State) => {
    state.str = 'abc';
    return;
});

Current output

Specify which ES version you're targeting: ES2020

const reducer = (state) => {
    state = { ...state, str: 'abc' };
    return;
    return state;
};

There are 2 returns, and the first should just be removed entirely.

@michaelboyles michaelboyles added the bug Something isn't working label Nov 6, 2021
@michaelboyles michaelboyles self-assigned this Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant