Open sregg opened 4 years ago
Here's the code to repro:
import { createAction, createReducer } from 'redux-promise-middleware-actions';
interface IState {
name: string;
}
const INITIAL_STATE: IState = {
name: '',
};
const setName = createAction('SET_NAME', (name: string) => ({ name }));
export const NameReducer = createReducer(INITIAL_STATE, handleAction => [
// intro screen
handleAction(setName, (state, action) => ({
...state,
nane: action.payload.name,
})),
]);
Good point, I will try and add this. If you have a solution a PR is of course very welcome :)
Currently it would actually give you a warning if you only set the name
property, but because you are spreading the state (...state
) it has already set name
(to the old value) and will not warn you because you are allowed to extend the object with a new nane
prop.
See line 17
nane: action.payload.name
, TS is nit complaining about that I typednane
instead ofname
.If I add the type manually:
Then I see the error fine.
Is there a way to have the error without the manual type?
Thanks