Angular 2: the 'toPromise' property does not exist in the type 'Observable <Response>'
I am developing an Angular 2 project and following the Http Client Guide to implement an HTTP request. But getting the following error when using the RsJx module,
Property 'toPromise' does not exist in type 'Observable'
I did the following, but the error still persists:
- Added
import 'rxjs/add/operator/toPromise'; to the service module - Checks the version of the
RxJslibrary for any dependency. - imported all modules from the
RxJs library
Here you can find my source code here on Github. Read what I do and what I miss. Thank.
You can find all the imports in the rxjs-operator.ts file, and I referenced it in the app.component.ts file to make it global, but still I have an error in the dragon.service.ts file. Moreover, the same error is shown for .map ().
You can find all version information in the package.json file.
Additional Information:
- node version: v4.4.7
- version for npm: v3.10.5
- angular version: 2.0.0-rc.4
- RxJs Version: 5.0.0-beta.6
Note. . Now I have commented on the code, but you can change it as you wish.
Please check: Angular 2 2.0.0-rc.1 The 'map' property does not exist in the 'Observable <Response>' type is not the same as the release report
"For VS 2015 (update 3):
Install update VS 2015 3 Replace C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TypeScript \ typescriptServices.js with the file https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518 -U3 / lib / typescriptServices.js . Make a local backup first.
In this workaround, the " Property" problem for the "Does Not Exist " setting is for me.
I think this is a bug in Visual Studio (I assume you see this behavior in VS2015?) I have exactly this problem when I try to work with Angular2 application in VS2015.
As work around, you can try working with your project using the Visual Studio code instead. I opened your link repository using VS Code and confirmed that it had intellisense for rxjs extensions (e.g. toPromise), as expected. However, as you say, in VS2015 rxjs extensions were not found and are displayed as errors.