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

前端 未结 9 2394
灰色年华
灰色年华 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 19:09

    You can add a path mapping in your tsconfig.json to map the rxjs in your dependency to the one in your node_modules folder:

    {
      "compilerOptions": {
        "baseUrl": ".",
        "paths": {
          "rxjs": ["node_modules/rxjs"]
        }
    }
    

    more documentation is available at the Typescript site

提交回复
热议问题