Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

while this looks like same issue as Angular 2 beta.17: Property 'map' does not exist on type 'Observable<Response>'

this is a new version and those solutions don't work for this new released version

I've update to the latest Angular 2 rc1 and can't get things to compile. I had issues with not recognizing 'Promise' I ended up installing es6-promise typing directly to resolve that issue. I have tried putting in various import statements but no luck. I'm running in visual studio 2015

import 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';

return this._http.post(url, null, args).map(extractData).toPromise();

but continue to get the property 'map' does not exist on type 'Observable'

my package file is

"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",


"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",

"bootstrap": "^3.3.6",
"breeze-client": "~1.5.6",
"handlebars": "^4.0.5"
},
"devDependencies": {
"typescript": "^1.8.10",
"typings": "^0.8.1",
"gulp": "^3.9.1",
"jasmine-core": "~2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-coverage": "^0.5.5",
"remap-istanbul": "^0.6.3",
"karma-jasmine": "^0.3.8",
"karma-jasmine-html-reporter": "^0.2.0",
"http-server": "^0.9.0"
}
like image 380
Dan Soltesz Avatar asked May 04 '16 14:05

Dan Soltesz


4 Answers

did you try with this import? it works for me

 import {Observable} from 'rxjs/Rx';
 import 'rxjs/add/operator/map';
like image 195
Apostolos Avatar answered Nov 10 '22 02:11

Apostolos


Here is the workaround. jjokela and VahidN hinted at it also with their comments. I found it by looking at Deborah Kurata's blog post here. She outlines using Angular2 with ASP.NET 4 project template not the new ASP.NET 5 RC template I'm using.

To fix please refer to these instruction found at https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-229506507

This fix is targeted to be included with the Typescript 2.0 release for Visual Studio. Until you can perform the manual steps below.

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.

For VS 2015 (Update 2):

Install VS 2015 Update 2 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/lib/typescriptServices.js. First take a local backup though.

For VS 2013:

Install TypeScript 1.8.5 (https://www.microsoft.com/en-us/download/details.aspx?id=48739) Replace C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-Dev12/lib/typescriptServices.js. First take a local backup though.

like image 34
Eric Weiss Avatar answered Nov 10 '22 04:11

Eric Weiss


I was having the same issue. It seems to have resolved after adding this line to the AppComponent class.

import 'rxjs/Rx'; 
like image 14
NeshDev Avatar answered Nov 10 '22 03:11

NeshDev


Nothing except

import { Observable } from 'rxjs/Rx';
like image 6
Varun Kumar Avatar answered Nov 10 '22 03:11

Varun Kumar