ngneat / effects

🪄 A framework-agnostic RxJS effects implementation
https://www.netbasal.com
MIT License
63 stars 11 forks source link

Parameters not assignable to parameter of type #37

Open tibdev78 opened 1 year ago

tibdev78 commented 1 year ago

Which @ngneat/effects-* package(s) are the source of the bug?

effects

Is this a regression?

No

Description

I'm trying to put ngneat/effects on my ionic project but I get an error I don't understand, when I put the 'ofType' operator to observe my action it triggers this error:

Argument of type '(source: Observable<Action<string>>) => Observable<{ type: "[Spending] Load Spendings"; }>' is not assignable to parameter of type 'OperatorFunction<Action, { type: "[Spending] Load Spendings"; }>'.

it tells me it's a ts error, so I try to change the node version but nothing I still get the same error.

My action:

import { actionsFactory } from "@ngneat/effects";

const spendingActions = actionsFactory('Spending');

const loadSpending = spendingActions.create('[Spending] Load Spendings');

export { loadSpending };

my effect:

loadingSpendings$ = createEffect((actions) => 
        actions.pipe(
            ofType(spendingActions.loadSpending), // error triggered here
            mergeMap(() => 
                this.spendingService.loadSpending()
            ),
            tap(setSpendings),
        )
    )

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

Node version: 18.10
Ts version: 4.8.4

Anything else?

No response

Do you want to create a pull request?

No

NetanelBasal commented 1 year ago

Please reproduce it on stackblitz

royling commented 1 year ago

This happened to me, too. I believe it's because the ts-action-operators (which exports the ofType operator) is requiring the local rxjs lib, I can see the below structure in the node_modules directory: image

with a global dep of rxjs in the project, there're always such different references to the same type.