ESLint无法识别打字稿的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
抑制,但是我仍然想要对此做一个解释,并找到一个永久性的解决方案,这样我就不会得到这个错误Error。
我有同样的问题,在.eslintrc.js配置中,将'no-undef':'off'配置添加到规则中,这解决了错误报告问题,但是创建了一个新问题,我无法重新启动我的项目,您有更好的解决方案吗?