[英]combineReducers return type is inferred to have type any
我在 JSDocs 上使用 typescript 並且我在輸入我的應用程序的根 state 時遇到了麻煩。 Following redux documentation about how to use it with typescript, I try to use the return type of my root reducer as the root state state but it infers to be any. 我不確定這是否只是我的 redux 版本上的錯誤或什么。 這是我的代碼片段:
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
const homeReducer = (state: {cool: boolean}) => state
const reducerMap = {
router: routerReducer,
home: homeReducer,
};
/** @typedef {ReturnType<typeof rootReducer>} RootState*/
const rootReducer = combineReducers(reducerMap);
export default rootReducer;
我從中得到的類型是type RootState = any
。 我的redux版本是3.7.2
因此,看起來 redux 版本 3.7.2 不包含正確的類型。 希望它很容易升級到 4.0.5,現在我發布的類型是正確的。 如果有人有興趣查看此 PR 上的升級更改: 合並請求
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.