使用rxjs beta2,我的项目工作得很好,但是更新到beta6会得到一长串编译错误列表:
component.ts(34,18): error TS2339: Property 'finally' does not exist on type 'Observable<T[]>'.
....
....
.component.ts(51,10): error TS2339: Property 'switchMap' does not exist on type 'Observable<Company>'.
....
....
service.ts(24,18): error TS2339: Property 'map' does not exist on type 'Observable<Response>'
....
....
node_modules/rxjs/add/observable/range.d.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules.
node_modules/rxjs/add/observable/range.d.ts(2,16): error TS2436: Ambient module declaration cannot specify relative module name.
node_modules/rxjs/add/operator/catch.d.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules.
node_modules/rxjs/add/operator/catch.d.ts(2,16): error TS2436: Ambient module declaration cannot specify relative m
..
我在进口这样的可观察仪器:
import {Observable} from 'rxjs/Observable';
我做错了什么?
非常感谢
使用rc1 rxjs beta6工作来编辑。但我不得不把结果投给我所有的观察对象。在我能用上之前
this._couseSourcesSvc.readAll ()
.finally (() => sourcesSpinner.hide ())
.subscribe (
res => {
this.sources = res;
}
但现在我得用:
this._couseSourcesSvc.readAll ()
.finally (() => sourcesSpinner.hide ())
.subscribe (
(res:Sources[]) => {
this.sources = res;
}
如您所见,我必须强制转换结果,否则将得到一个编译错误(res:Sources[])
Type '{}' is not assignable to type 'DocumentSource[]'.
这是正常的吗?
发布于 2016-05-03 19:46:03
只有Angular2 rc.0
(昨晚刚刚发布)支持rx 6。
升级您的角度,以释放候选1,以便能够更新RxJ。
注意,您必须将您的导入更新为
@angular/core
、@angular/http
等。名称已从angular2/*
更改
https://stackoverflow.com/questions/37013041
复制相似问题