Angular/rxjs:为什么我不必再导入toPromise? [英] Angular/rxjs: Why don't I have to import toPromise anymore?
问题描述
一堆SO回答说是为了避免诸如此类的问题
A ton of SO answers say that to avoid problems like
类型可观察"的属性"toPromise"不存在
Property 'toPromise' does not exist on type 'Observable'
在Angular中,您必须导入直到最近才完成的'rxjs/add/operator/toPromise'.在Angular 4.2.4项目中,我忘记了导入并期望看到错误.不在那里!我在Chrome的开发工具中进行了一些调试,并在Observable的原型上看到了"toPromise".
in Angular, you have to import 'rxjs/add/operator/toPromise' which I've done until recently. In an Angular 4.2.4 project, I forgot the import and expected to see an error. It wasn't there! I did some debugging in Chrome's dev tools and saw "toPromise" on the Observable's prototype.
我的问题是...那是怎么到达那里的?这是TypeScript,Angular或rxjs的新功能吗?
My question is ... how did that get there? Is this a new addition to TypeScript, Angular, or rxjs?
推荐答案
从rxjs 5.5.0-beta.5起
As of rxjs 5.5.0-beta.5
toPromise:现在作为Observable(2e49a5c)上的永久方法存在
toPromise: now exists as a permanent method on Observable (2e49a5c)
https://github.com. com/ReactiveX/rxjs/blob/master/CHANGELOG.md#550-beta5-2017-10-06
这篇关于Angular/rxjs:为什么我不必再导入toPromise?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!