【问题标题】:typescript Cannot invoke an expression whose type lacks a call signature?typescript 无法调用类型缺少调用签名的表达式?
【发布时间】:2016-05-21 11:00:32
【问题描述】:

我像这样在typescript 中打电话给combineReducers (import { combineReducers } from 'redux-immutable'):

return combineReducers({
    byId,
    visibleIds
})(state, action)

但是打字稿抱怨这个:

Cannot invoke an expression whose type lacks a call signature.

所以我看到了类型定义文件:

declare module "redux-immutable" {
    export function combineReducers(reducers : Object): Object;
}

如何正确调用combineReducer

【问题讨论】:

    标签: reactjs typescript redux


    【解决方案1】:

    类型定义错误,应该可以:

    declare module "redux-immutable" {
        export function combineReducers(reducers : Object): Function;
    }
    

    虽然类型定义是官方的Redux typings是:

    function combineReducers<S>(reducers: ReducersMapObject): Reducer<S>;
    

    【讨论】:

      猜你喜欢
      • 2017-09-01
      • 2021-02-06
      • 1970-01-01
      • 2019-09-28
      • 2019-09-10
      • 2018-12-25
      • 1970-01-01
      • 2015-08-26
      相关资源
      最近更新 更多