rxjs/Subject.d.ts error : Class 'Subject' incorrectly extends base class 'Observable'

前端 未结 19 1921
一向
一向 2020-12-01 09:55

I extracted sample template code from this tutorial and did below two steps to get started -

  1. npm install // worked fine and created node_modules folder
相关标签:
19条回答
  • reinstalling rxjs -> npm install rxjs@6 rxjs-compat@6 --save

    0 讨论(0)
  • 2020-12-01 10:32

    thanks the answer of zmag and Rahul Sharma, it works! @zmag @Rahul Sharma

      "rxjs": "5.4.1",
      "typescript": "~2.4.0"
    

    my problem is as follow:

    typings/globals/core-js/index.d.ts:3:14 - error TS2300: Duplicate identifier

    Make changes as.

    GO to Package.json file and modify the below configuration

      "rxjs": "5.4.1",
      "typescript": "~2.4.0"
    
    0 讨论(0)
  • 2020-12-01 10:33

    GO to Package.json file and modify the below configuration

    ...
      "rxjs": "5.4.1",
      "typescript": "~2.4.0"
    ...
    

    It will work

    0 讨论(0)
  • 2020-12-01 10:34

    Just a little bit of detail, in an attempt to put in my two cents.

    The problem arises when we upgrade Typescript to the latest version, which by now was TypeScript 2.4.1, [ "as we love the upgrades : )" ], and as mentioned by @Jonnysai in his answer and the link provided there, there is a detailed discussion regarding the problem and its fixes.

    So, what worked for me was:
    1. I had to Uninstall TypeScript 2.4.1 first, by going to Control Panel > Programs and Features...
    2. Install, afresh, TypeScript 2.4.0, and then make sure, in package.json file, you have this


    configuration, as mentioned here in a rather shorter detail.

    You can download TypeScript 2.4.0 from here, for Visual Studio 2015

    0 讨论(0)
  • 2020-12-01 10:37

    As per this you need update typescript 2.3.4 or rxjs 6 alpha

    go the your package.json file in your project update typescript or rxjs version. Example

    "typescript": "2.3.4"
    

    do npm install

    update(06/29/2017):-

    As per the comments typescript "2.4.0" working.

    0 讨论(0)
  • 2020-12-01 10:40

    Please change the following line of Subject.d.ts file:

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

    to:

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

    The return type should probably be Observable<R> rather than Observable<T>

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