How do I get around this “Subject incorrectly extends Observable” error in TypeScript 2.4 and RxJS 5.x?

后端 未结 9 1470
囚心锁ツ
囚心锁ツ 2020-12-05 06:33

When I compile, I get the following compiler error in the RxJS declaration files:

node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class \'Subject

        
相关标签:
9条回答
  • 2020-12-05 06:57

    In your Subject class:

    change this line:

    lift<R>(operator: Operator<T, R>): Observable<T>;
    

    to :

    lift<R>(operator: Operator<T, R>): Observable<R>;
    
    0 讨论(0)
  • 2020-12-05 07:06

    Today, faced this error and solved this pratically with the below three steps. So sharing the same with the hope, it will help others.

    Step 1: In the package.json file change the entry as "rxjs": "5.4.2",

    Step 2: Delete the node_modules folder from the project,which is present in the root directory

    Step 3 : Now ,Right click the package.json file and click restore like as shown below:

    Note : It will again create node_module folder with the new files, Now build the solution, hopefully you should not get any build error related to above problem.

    0 讨论(0)
  • 2020-12-05 07:09

    I have made the below two changes in package.json file.

    1) changed the rxjs version to 5.4.1 in dependencies section.

    "dependencies": {
    "rxjs": "5.4.1" }

    2) changed the typescript version to 2.4.0 in devDependencies section.

    "devDependencies": { "typescript": "2.4.0" }

    I ran 'npm install' command after making the two changes and it worked.

    0 讨论(0)
提交回复
热议问题