【发布时间】:2019-03-15 11:19:57
【问题描述】:
我在这里关注关于 redux + typescript 的微软教程:https://github.com/Microsoft/TypeScript-React-Starter 但不知何故在最后一部分我被卡住了:
const store = createStore<StoreState, any, any, any>(
enthusiasm,
{
enthusiasmLevel: 1,
languageName: 'TypeScript'
},
composeEnhancers(applyMiddleware(thunk))
);
这是我在下面的屏幕截图中遇到的错误:
Argument of type '(state: StoreState, action: EnthusiasmAction) => StoreState' is not assignable to parameter of type 'Reducer<StoreState, any>'.
Types of parameters 'state' and 'state' are incompatible.
Type 'StoreState | undefined' is not assignable to type 'StoreState'.
Type 'undefined' is not assignable to type 'StoreState'.ts(2345)
我相信我已经关注了一切,在这里,我也想添加 thunk,但是我在争论的热情上遇到了错误,我不知道为什么,帮助?
【问题讨论】:
标签: javascript reactjs typescript redux