question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript error if trying to combine only one epic ...

See original GitHub issue

First, thanks for this very neat library !

Here’s a weird error when used with redux-observable … if trying to combineEpics only one epic !

I know combineEpics is useless with only one epic … but if you have 2 epics, and you want to momentary disable one, it shouldn’t be a problem IHMO.

I’ve reproduced the issue based one the example given in the docs : https://deox.js.org/faq#using-redux-observable-with-deox

Here’s my CodeSandbox “fork” : https://codesandbox.io/s/redux-observable-example-4g1lt

The only thing I changed from the given one (https://codesandbox.io/s/redux-observable-example-z6sdk) is to replace combineEpics(fetchAllTodosEpic, addTodoEpic) by combineEpics(addTodoEpic) in todos.ts.

The error then pops all the way in create-store.ts on epicMiddleware.run(rootEpic) :

(alias) const rootEpic: (action$: Observable<{
    type: "TODO_ADD_NEXT";
    payload: {
        title: string;
        completed: any;
    };
} | {
    type: "TODO_ADD_ERROR";
} | {
    type: "TODO_ADD_ERROR";
    payload: any;
    error: true;
} | {
    type: "TODO_ADD_ERROR";
    payload: any;
} | {
    ...;
} | {
    ...;
}>, _state$: Observable<...>, { api }: {
    ...;
}) => Observable<...>
import rootEpic
L'argument de type '(action$: Observable<{ type: "TODO_ADD_NEXT"; payload: { title: string; completed: any; }; } | { type: "TODO_ADD_ERROR"; } | { type: "TODO_ADD_ERROR"; payload: any; error: true; } | { type: "TODO_ADD_ERROR"; payload: any; } | { ...; } | { ...; }>, _state$: Observable<...>, { api }: { ...; }) => Observable<...>' n'est pas attribuable au paramètre de type 'Epic<Action<any>, Action<any>, void, { api: typeof import("/sandbox/src/store/api"); }>'.
  Les types des paramètres '_state$' et 'state$' sont incompatibles.
    Impossible d'assigner le type 'StateObservable<void>' au type 'Observable<{ todos: Todo[]; isFetching: boolean; }>'.
      Les types de la propriété 'operator' sont incompatibles.
        Impossible d'assigner le type 'Operator<any, void>' au type 'Operator<any, { todos: Todo[]; isFetching: boolean; }>'.
          Impossible d'assigner le type 'void' au type '{ todos: Todo[]; isFetching: boolean; }'.ts(2345)

Any insight on this ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JalilArfaouicommented, Jul 11, 2019

As I said, the error pops in create-store.ts on epicMiddleware.run(rootEpic) :

image

0reactions
the-dr-lazycommented, Sep 26, 2019

It’s related to redux-observable @creaux. You can follow it on https://github.com/redux-observable/redux-observable/issues/592.

Read more comments on GitHub >

github_iconTop Results From Across the Web

combineEpics using TypeScript gives type error - Stack Overflow
I have pretty much the same problem. It seems like typescript grabs the first epic, infers it's type and expect all the rest...
Read more >
Troubleshooting - redux-observable
Happens from combineEpics(). Usually this means you're not returning an observable from one or more of your Epics. Often this is just a...
Read more >
How to use React Context effectively - Kent C. Dodds
In Application State Management with React, I talk about how using a mix of local state and React Context can help you manage...
Read more >
Announcing TypeScript 4.4 - Microsoft Developer Blogs
Tools like the TypeScript compiler just erase those types, ... In previous versions of TypeScript, this would be an error – even though ......
Read more >
Observable | RxJS API Document - ReactiveX
It's just like bindCallback, but the callback is expected to be of type callback(error, result) . bindNodeCallback is not an operator because its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found