감속기를 쓰고 있는데 RESET을 수행하려면 state.count = 0
을 사용하십시오. 그러나,이 날 number is not assignable to type CounterState
오류가 발생합니다. 내가 lodash의 할당 기능을 사용하고TypeScript 오류 번호를 할당 할 수 없습니다.
export interface CounterState {
count: number;
};
const initialState: CounterState = {
count: 0
};
export default function counter(state = initialState, action: Action): CounterState {
switch (action.type) {
case TYPES.INCREMENT:
return assign({}, state, {
count: state.count + 1
});
case TYPES.DECREMENT:
return assign({}, state, {
count : state.count - 1
});
case TYPES.RESET:
//error here
return state.count=0;
default:
return state;
}
}
:
여기 내 코드입니다. 감사합니다