我从 本教程中提取了样本模板代码,并执行了以下两个步骤来开始-
npm install // worked fine and created node_modules folder with all dependencies
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>'
incorrectly extends base class 'Observable<T>'.
Types of property 'lift' are incompatible.
Type '<T, R>(operator: Operator<T, R>) => Observable<T>' is not assignable
to type '<R>(operator: Operator<T, R>) => Observable<R>'.
Type 'Observable<T>' is not assignable to type 'Observable<R>'.
Type 'T' is not assignable to type 'R'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
I see that in the subject.d.ts declaration of lift is as below -
lift<T, R>(operator: Operator<T, R>): Observable<T>;
在 Observatory able.ts 中,它的定义如下-
lift<R>(operator: Operator<T, R>): Observable<R> {
注:- 1. 我是 Angular2的新手,正在努力掌握一些东西。
误差可能是由于提升法的定义不一致造成的
我通读了这本 Github 线
如果我需要安装一些不同版本的 rxjs,请告诉我如何卸载和安装正确的 rxjs。
编辑1: 这里我可能有点晚了,但是即使在使用 打印稿2.3.4或 RXJS6A之后,我仍然得到相同的错误。下面是我的包 json,
{
"name": "angular-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "6.0.0-alpha.0",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.2.0",
"lite-server": "^2.2.2",
"typescript": "2.3.4",
"typings": "^1.3.2"
}
}