简体   繁体   English

具有输入值的函数的返回类型

[英]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<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??如何调用函数来获得相同的返回类型??

You can just use ReturnType twice:您可以只使用ReturnType两次:

const rootReducer = history =>
    combineReducers({
        router: connectRouter(history),
        page: pageReducer,
    });

export type AppState = ReturnType<ReturnType<typeof rootReducer>>;

Playground Link 游乐场链接

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

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