小编kmw*_*ter的帖子

在调用 combineReducers 时隐式实例化的函数类型中声明的类型参数缺少类型注释

我现在在 Redux 中的 combineReducers 上收到以下错误。

缺少类型注释AA是在函数类型 [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 …

javascript instantiation implicit flowtype redux

5
推荐指数
1
解决办法
2645
查看次数

标签 统计

flowtype ×1

implicit ×1

instantiation ×1

javascript ×1

redux ×1