2
votes

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

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

I have done the following but error still persist:

  • Added import 'rxjs/add/operator/toPromise'; to service module
  • Checked the version of RxJs library for any dependency.
  • imported all modules from RxJs library

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

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.

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

Additional details are:

  • node version: v4.4.7
  • npm version: v3.10.5
  • angular version: 2.0.0-rc.4
  • RxJs version: 5.0.0-beta.6

Note: For now I have commented the code but you can modify as you like.

2

2 Answers

6
votes

Please check out : Angular 2 2.0.0-rc.1 Property 'map' does not exist on type 'Observable<Response>' not the same as issue report

"For VS 2015 (Update 3):

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."

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

1
votes

I think this is a bug in Visual Studio (I'm guessing you're seeing this behavior in VS2015?) I have exactly this issue when I try working with an Angular2 app in VS2015.

As a work around you might try working with your project using Visual Studio Code instead. I opened your referenced repository using VS Code and verified it had intellisense for rxjs extensions (like toPromise) as expected. However, as you sate, in VS2015 rxjs extensions are not being found and show as errors.