ESLint无法识别typescript中的Partial
,但编译后的模块没有出现任何错误。
const initialState: IAuthState = {
authenticated: false,
processing: false,
};
const authReducer = (state: IAuthState = initialState, action: any): IAuthState => {
const State = (newState: Partial<IAuthState>): IAuthState => ({...state, ...newState});
switch (action.type) {
case Actions.SIGN_IN_PROCESS_INITIATED:
return State({processing: true});
case Actions.SIGN_IN_PROCESS_FAILED:
return State({processing: false});
default:
return state;
}
};
我知道可以通过// eslint-disable-next-line no-undef
来禁止该错误,但我仍然想要一个解释和一个永久的解决方案,以便我不会再遇到这个不太好的错误。