redux-observables + Typescript Uncaught TypeError: this.schedulerActionCtor is not a constructor, when running rootEpic

Viewed 726

I'm trying to follow an example project to get my head around redux-observables and how it works with typescript, and I've been following some guides here and here, but I keep running into this error no matter how I've go about setting up the epics/middleware:

Uncaught TypeError: this.schedulerActionCtor is not a constructor
    at QueueScheduler.Scheduler.schedule (Scheduler.js?ef44:10)
    at eval (observeOn.js?142b:6)
    ...

When trying to set up the middleware, below is the code I'm trying to get working.

example/epics.ts:

import { delay, filter, mapTo } from 'rxjs/operators'
import { isOfType } from "typesafe-actions"

import { ExampleActionTypes } from './types'
import * as exampleActions from './actions'


export const pingEpic: Epic<RootAction, RootAction, RootState> = (action$) => action$.pipe(
  filter(isOfType(ExampleActionTypes.PING)),
  delay(1000), // Asynchronously wait 1000ms then continue
  mapTo(exampleActions.pong())
)

export const buttonEpic: Epic<RootAction, RootAction, RootState> = (action$) => action$.pipe(...)

export default {
  pingEpic, 
  buttonEpic
}

Then in rootEpic.ts:

import { combineEpics } from 'redux-observable';
import {
  pingEpic,
  buttonEpic
} from './example/epics';


export default combineEpics(
  pingEpic,
  buttonEpic
)

And in store.ts:

...
export const epicMiddleware = createEpicMiddleware<RootAction, RootAction, RootState>()

const middlewares = [epicMiddleware]
const enhancer = composeEnhancers(applyMiddleware(...middlewares))

const store = createStore(
  rootReducer,
  initialState,
  enhancer
)

epicMiddleware.run(rootEpic)
...

Versions of libraries from package.json

    "redux": "4.1.0",
    "redux-observable": "1.2.0",
    "typesafe-actions": "5.1.0"

Also, if I comment out the epicMiddleware.run(rootEpic) line then the error goes away, but I don't really know what that tells me besides I have a problem with either my epics or the middleware. I can't spot where my types don't line up or if there's a step I'm missing somewhere?

1 Answers

Upgrading versions to redux-observable@2.0.0-rc.2 fixed the issue (from this issue on the redux-observables repo).

Related