使用 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
..
我正在像这样导入 Observables:
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[]'.
这是正常的吗?