角度2:类型"Observable< Response>"上不存在属性"toPromise" [英] Angular 2: Property 'toPromise' does not exist on type 'Observable<Response>'

查看:82
本文介绍了角度2:类型"Observable< Response>"上不存在属性"toPromise"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Angular 2项目,并遵循 Http客户端指南用于实现HTTP请求,但在使用RsJx模块时收到以下错误.

I'm developing Angular 2 project and following Http Client Guide for implementing HTTP request But receiving following error when using RsJxmodule.

类型可观察"的属性"toPromise"不存在

Property 'toPromise' does not exist on type 'Observable'

我已完成以下操作,但错误仍然存​​在:

I have done the following but error still persist:

  • import 'rxjs/add/operator/toPromise'; 添加到服务模块
  • 检查了RxJs库的版本是否存在任何依赖性.
  • RxJs library
  • 导入了所有模块
  • Added import 'rxjs/add/operator/toPromise'; to service module
  • Checked the version of RxJs library for any dependency.
  • imported all modules from RxJs library

您可以在Github上此处找到我的源代码.请指导我该怎么办以及我缺少什么.谢谢.

You can find my source code here on Github. Please guide what should I do and what I'm missing. Thank you.

您可以在 rxjs-operators.ts 文件中找到所有导入,我已经在 app.component.ts 文件中对其进行了引用,以使其仍然是全局的 dragon.service.ts 文件中有错误. 此外,.map()也显示相同的错误.

You can find all the imports in rxjs-operators.ts file and I have referenced it in app.component.ts file to make it global BUT still I am having error in dragon.service.ts file. Moreover, same error is shown for .map() as well.

您可以在 package.json 文件中找到所有版本详细信息.

You can find all the version details in package.json file.

其他详细信息是:

  • 节点版本:v4.4.7
  • npm版本:v3.10.5
  • 角度版本:2.0.0-rc.4
  • RxJs版本:5.0.0-beta.6

注意: 目前,我已经注释了该代码,但是您可以根据需要进行修改.

推荐答案

请签出: 角度2 2.0.0-rc.1类型"Observable< Response>"上不存在属性"map"与问题报告不同

对于VS 2015(更新3):

"For VS 2015 (Update 3):

安装VS 2015 Update 3将C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TypeScript \ typescriptServices.js替换为

Install VS 2015 Update 3 Replace C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-U3/lib/typescriptServices.js. First take a local backup though."

此替代方法为我解决了"属性'toPromise'不存在"的问题.

This workaround fixed the "Property 'toPromise' does not exist " issue for me.

这篇关于角度2:类型"Observable&lt; Response&gt;"上不存在属性"toPromise"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆