We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, August 8, 2018

If we run the program in Angular then many times we have seen this like error
So today we will see how to resolve this error. See the below description error

node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
         Type 'T' is not assignable to type 'R'.

So now how do resolve this error


Solution

Newer versions of RxJS will have this fixed, but as a temporary workaround, you can use the noStrictGenericChecks compiler option.

go to  tsconfig.json, and  put it in "compilerOptions" and set it to true.

"compilerOptions": {
 "noStrictGenericChecks": true }
 }


On the command line it's --noStrictGenericChecks.

Why it's happening

TypeScript 2.4 has a strictness change, and Subject<T> isn't lifting to the correct Observable. 
The signature really should have been<R>(operator: Operator<T, R>) => Observable<R>

No comments: