'Observable' is not a class derived from 'Observable'

前端 未结 9 2448
灰色年华
灰色年华 2020-12-29 18:11

When trying to extend a class from a class in a node_modules the typescript compiler throws a error saying:

Property \'source\' is protected but

9条回答
  •  星月不相逢
    2020-12-29 19:09

    After listing rxjs modules:

    npm list rxjs

    +-- @angular/cli@1.6.6 | +-- @angular-devkit/core@0.0.29 | | -- rxjs@5.5.10 | +-- @angular-devkit/schematics@0.0.52 | |-- rxjs@5.5.10 | -- rxjs@5.5.10 -- rxjs@5.5.6

    You can see 2 versions of the same module. My project required lower version of rxjs, and e.g. anglular/cli required higher version of rxjs.

    It didn't cause any problems before but suddenly all projects with the same dependencies were throwing the same TS90010 errors e.g.:

    ERROR in [at-loader] ./src/main/webapp/app/admin/user-management/user-management-detail.component.ts:23:9 TS90010: Type 'Subscription' is not assignable to type 'Subscription'. Two different types with this name exist, but they are unrelated.

    Property '_parent' is protected but type 'Subscription' is not a class derived from 'Subscription'.

    Finally I updated typescript version in package.json from 2.6.2 to 2.9.2 an all errors disappeared.

提交回复
热议问题