繁体   English   中英

Redux 工具包 typescript 类型问题与 next js 和 next-redux-wrapper

[英]Redux toolkit typescript type issue with next js and next-redux-wrapper

StackBlitz 演示

我在这里按照 redux 工具包的设置为下一个 js 设置。 但是,在原始问题的tsconfig.json中, compilerOptions.strict = false而我的是true 我遇到的问题在store.js中。 如果你看演示,当调用configureStore时,reducer 有以下问题:

Type '(state: ReturnType<typeof combinedReducer>, action: AnyAction) => any' is not assignable to type 'Reducer<CombinedState<{ counter: CounterState; kanyeQuote: KanyeState; }>, AnyAction> | ReducersMapObject<CombinedState<{ counter: CounterState; kanyeQuote: KanyeState; }>, AnyAction>'.

任何帮助表示赞赏。

您可以将reducer定义更改为

const reducer: typeof combinedReducer = (state, action) => {

那么它会工作得很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM