After updating to TypeScript 2.4.1, compiling projects that use the Actions
observable from @ngrx/effects
(version 2.0.3) sees the following error thrown:
Error TS2684: The 'this' context of type 'Actions' is not assignable to method's 'this' of type 'Observable<any>'.
Error TS7006: Parameter 'action' implicitly has an 'any' type.
Error TS2345: Argument of type 'Actions' is not assignable to parameter of type 'Observable<Action>'.
Types of property 'lift' are incompatible.
Type '(operator: Operator<any, Action>) => Observable<Action>' is not assignable to type '<R>(operator: Operator<Action, R>) => Observable<R>'.
Types of parameters 'operator' and 'operator' are incompatible.
Type 'Operator<Action, R>' is not assignable to type 'Operator<any, Action>'.
Type 'R' is not assignable to type 'Action'.
How can this be resovled?
TypeScript 2.4.1 more strictly enforces the the generic signature of the lift
method in Observable
and the Actions
observable's implementation of lift
fails the check.
The check can be disabled using the --noStrictGenericChecks
command line flag or the noStrictGenericChecks
compiler option (as a parameter in tsconfig.json
's "compilerOptions"
object).
An alternative to disabling the checks is to use TypeScript's interface augmentation to specify a correct signature:
import { Action } from "@ngrx/store";
import { Observable } from "rxjs/Observable";
import { Operator } from "rxjs/Operator";
declare module "@ngrx/effects/src/actions" {
interface Actions {
lift<R>(operator: Operator<Action, R>): Observable<R>;
}
}
Note that the full path to the module/file must be used; it's not sufficient to specify @ngrx/effects
as the module name.
This has been resolved with the release of @ngrx/effects
2.0.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With