typescript无法调用类型缺少调用签名的表达式?

时间:2016-05-21 11:00:33

标签: reactjs typescript redux

我在combineReducers中拨打import { combineReducers } from 'redux-immutable'typescript),如下所示:

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

1 个答案:

答案 0 :(得分:1)

类型定义错误,这应该有效:

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

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

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