Typescript 类型';R[P]&x27;不满足约束';(…args:any)=>;任何';

Typescript 类型';R[P]&x27;不满足约束';(…args:any)=>;任何';,typescript,redux,reselect,Typescript,Redux,Reselect,我正在尝试将重选和重选与typescript集成。我正在出口各种类型的减速器。这是我喜欢的类型 type Reducers = { user: Reducer<{ isLogged: boolean; isLogging: boolean; isFinished: boolean; response: { idToken: string; sessionState: st

我正在尝试将重选和重选与typescript集成。我正在出口各种类型的减速器。这是我喜欢的类型

type Reducers = {
    user: Reducer<{
        isLogged: boolean;
        isLogging: boolean;
        isFinished: boolean;
        response: {
            idToken: string;
            sessionState: string;
            accessToken: string;
            refreshToken: string;
            tokenType: string;
            scope: string;
            profile: {
                ...;
下面是我如何成功地完成它,但我得到了typescript错误。我相信这是因为ReturnType应该与箭头函数一起使用,比如
ReturnType R[P]>
,但这并没有给出我想要的结果

export type CreateState<R> = {
  [P in keyof R]: ReturnType<R[P]>
}
type State = CreateState<Reducers>
导出类型CreateState={
[P in keyof R]:返回类型
}
类型State=CreateState

您可以使其更通用,而无需任何额外类型:

导出类型CreateState={
[P in keyof R]:R[P]扩展(…args:any)=>any?返回类型:从不
}
export type CreateState<R> = {
  [P in keyof R]: ReturnType<R[P]>
}
type State = CreateState<Reducers>