我现在在 Redux 中的 combineReducers 上收到以下错误。
缺少类型注释A。A是在函数类型 [1] 中声明的类型参数,并在调用combineReducers[2] 时隐式实例化。
代码如下所示,但出现在我所有使用 combineReducers 的减速器中。
export default combineReducers({
status: ((state: boolean = true, action: Action) => {
switch (action.type) {
case 'START_SESSION':
case 'REFRESH_AUTH_SUCCEEDED':
case 'SIGN_IN_FAILED':
case 'SIGN_OUT':
return false;
default:
return state;
}
}: Reducer<*>),
});
Run Code Online (Sandbox Code Playgroud)
我相信这是因为 Redux flow-types 中的这种类型定义
declare export function combineReducers<O: Object, A>(reducers: O):
CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;
Run Code Online (Sandbox Code Playgroud)
我相信这与 Flow 的发布有关,版本 0.85.0 引入了一些与“隐式实例化”有关的东西。
我阅读了 Flow 自己的 Sam Goldman 在 Medium …