Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You must provide a root Epic to createEpicMiddleware #545

Open
temurih opened this issue Jul 3, 2018 · 4 comments
Open

You must provide a root Epic to createEpicMiddleware #545

temurih opened this issue Jul 3, 2018 · 4 comments

Comments

@temurih
Copy link

temurih commented Jul 3, 2018

Bug Report

Current Behavior
I am encountering this ts error when I am trying to use createEpicMiddleware.
Error: Property 'run' does not exist on type 'EpicMiddleware<Action<any>, {}, any, Action<any>>'
OR
Error: You must provide a root Epic to createEpicMiddleware

Reproduction

const epicMiddleware = createEpicMiddleware({
    dependencies: { ... }
});

let middleware: Middleware[] = [];
middleware.push(epicMiddleware);
...

export const configureStore = (initialState: object): Store<IStore> => {
    const store = createStore(
        rootReducer,
        initialState,
        applyMiddleware(...middleware)
    );

    epicMiddleware.run(rootEpic);

    return store;
};

This is the error I am getting,

Property 'run' does not exist on type 'EpicMiddleware<Action<any>, {}, any, Action<any>>'.

When I change the type of epicMiddleware to any, then it throws a runtime error, You must provide a root Epic to createEpicMiddleware

P.S. I am using the latest version of redux-observable (1.0.0)


When using older version of redux-observable (such as 0.18.0), this works fine,

const epicMiddleware = createEpicMiddleware(rootEpic, {
    dependencies: { ... }
});

let middleware: Middleware[] = [];
middleware.push(epicMiddleware);
...

export const configureStore = (initialState: object): Store<IStore> =>
    createStore(
        rootReducer,
        initialState,
        applyMiddleware(...middleware)
    );
@evertbouw
Copy link
Member

EpicMiddleware definitely does have the run method, so I'm going to guess this is a version mismatch in the typescript cache. The problem should disappear if you restart the typescript service/your editor after updating packages. If that doesn't work delete your node modules/lock file/clear npm cache and reinstall everything. That's probably overdoing it but it's what I do 😄

@temurih
Copy link
Author

temurih commented Jul 4, 2018

Well, I don't know if I want to do all that. Sounds like too much work, and still not sure if it works after. I would rather use the older version that works.

@jayphelps
Copy link
Member

@temurih can you submit a stackblitz or repo that reproduces the issue? Here's a working example: https://stackblitz.com/edit/typescript-u6vdf4

@evertbouw
Copy link
Member

A lot of work? Hmm it's just 3 commands and reopening your editor. It's the cure all whenever I don't trust the results

rm -rf node_modules yarn.lock
yarn cache clean
yarn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants