Fai*_*zer 5 pycharm typescript reactjs eslint typescript-eslint
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;
}
};
Run Code Online (Sandbox Code Playgroud)
我知道这可以被抑制,// eslint-disable-next-line no-undef
但我仍然想要一个解释和一个永久的解决方案,这样我就不会得到这个错误Error。
小智 8
我前段时间遇到过类似的情况,并通过安装@typescript-eslint/parser
为 devDependency 并将其包含在 eslint 配置中来修复它:
"extends": [..., "@typescript-eslint/parser"],
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1260 次 |
最近记录: |