使用TypeScript的combineEpics给出类型错误

使用TypeScript的combineEpics给出类型错误,typescript,rxjs,redux-observable,Typescript,Rxjs,Redux Observable,在组合史诗时,我遇到了以下错误: TS2345: Argument of type 'Epic<SessionAction, GlobalState, any>' is not assignable to parameter of type 'Epic<EmployeeAction, GlobalState, any>'. Type 'SessionAction' is not assignable to type 'EmployeeAction'. Types of p

在组合史诗时,我遇到了以下错误:

TS2345: Argument of type 'Epic<SessionAction, GlobalState, any>' is not assignable to parameter of type 'Epic<EmployeeAction, GlobalState, any>'.
Type 'SessionAction' is not assignable to type 'EmployeeAction'.
Types of property 'type' are incompatible.
  Type 'SessionActionTypes' is not assignable to type 'EmployeeActionTypes'.

我也有同样的问题。似乎typescript抓住了第一部史诗,推断出它的类型,并期望所有其他的都是一样的

我所做的是第一个演员

以您的代码为例:

import { Observable } from 'rxjs/Observable';
import { AnyAction } from 'redux';
import { combineEpics } from 'redux-observable';
import { fetchUserSession } from './sessionEpics';
import { fetchEmployee } from './employeeEpics';

export default combineEpics(
  fetchEmployee as Observable<AnyAction>,
  fetchUserSession
);
从'rxjs/Observable'导入{Observable};
从'redux'导入{AnyAction};
从'redux observable'导入{combinepics};
从“/SessionPics”导入{fetchUserSession};
从“/employeeEpics”导入{fetchEmployee};
导出默认组合(
将雇员视为可观察的,
fetchUserSession
);
或使用
combineEpics

导出默认组合(
我的雇员,
fetchUserSession
);

更好的解决方案可能是使用正确的类型:
AnyAction
Observable

从“redux”导入{AnyAction}
从“可观察的redux”导入{combineEpics,createEpicMiddleware}
从“rxjs”导入{Observable}
export const clientMiddleware=createEpicMiddleware(
组合电子学(
authenticateEpic(请求),
注册(请求)
))

您解决了这个问题吗?
import { Observable } from 'rxjs/Observable';
import { AnyAction } from 'redux';
import { combineEpics } from 'redux-observable';
import { fetchUserSession } from './sessionEpics';
import { fetchEmployee } from './employeeEpics';

export default combineEpics(
  fetchEmployee as Observable<AnyAction>,
  fetchUserSession
);
export default combineEpics<any>(
  fetchEmployee,
  fetchUserSession
);