英文:
Returntype of function with input value
问题
以下是要翻译的内容:
So basicly I want to render a returntype for my combined reducers which I do just fine by:
const rootReducer = combineReducers({
notes: notesReducer,
categories: categoriesReducer,
flyout: flyoutReducer
// more reducers
});
export type AppState = ReturnType
However if I were to accept a passed in value to the function I am having issues returning the types correctly. Example below:
const rootReducer = history =>
combineReducers({
router: connectRouter(history),
page: pageReducer,
....
....
export type AppState = ReturnType
How can I invoke the function to get the same returned types??
英文:
So basicly I want to render a returntype for my combined reducers which I do just fine by:
const rootReducer = combineReducers({
notes: notesReducer,
categories: categoriesReducer,
flyout: flyoutReducer
// more reducers
});
export type AppState = ReturnType<typeof rootReducer>;
However if I were to accept a passed in value to the function I am having issues returning the types correctly. Example below:
const rootReducer = history =>
combineReducers({
router: connectRouter(history),
page: pageReducer,
....
....
export type AppState = ReturnType<typeof rootReducer>;
How can I invoke the function to get the same returned types??
答案1
得分: 1
You can just use ReturnType
twice:
const rootReducer = history =>
combineReducers({
router: connectRouter(history),
page: pageReducer,
});
export type AppState = ReturnType<ReturnType<typeof rootReducer>>;
英文:
You can just use ReturnType
twice:
const rootReducer = history =>
combineReducers({
router: connectRouter(history),
page: pageReducer,
});
export type AppState = ReturnType<ReturnType<typeof rootReducer>>;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论