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

前端 未结 19 2102
一向
一向 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条回答
  •  抹茶落季
    2020-12-01 10:54

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

    In tsconfig.json, 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 isn't lifting to the correct Observable. The signature really should have been

    (operator: Operator) => Observable

    This will be fixed in RxJS 6.

提交回复
热议问题