Solvedangular update 2 to 4 has problem [ts] Property 'map' does not exist on type 'Observable<Response>'.

image

I need to how to solve

51 Answers

Ôťö´ŞĆAccepted Answer

I met the same problem with the angular cli 6.0.0 and rxjs 6.1.0. And I solved the problem by replacing the former code with latter code below.

import 'rxjs/add/operator/map';
this.myObservable().map(data => {})
import { map } from "rxjs/operators";
this.myObservable().pipe(map(data => {}))

This is the update guide for your reference: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md

Other Answers:

Not sure whether it's related or not, I found out the official document is using pipe() to chain the logic.
Have a look on https://angular.io/guide/http
My solution to solve this:

import { map } from 'rxjs/operators';
return this.http.post(`${environment.apiPrefix}/auth/login`, credential).pipe(map((res: any) => {
      console.log('res', res);
      return res;
    }));

import 'rxjs/add/operator/map';

I'm having the same issue, even though I imported the map from 'import 'rxjs/add/operator/map''
Property 'map' does not exist on type observable.
is this related with any typescript version or something else.

Angular apps rely on rxjs@5.5+ import map operator like this:
import { map } from "rxjs/operators";

And if you're using rxjs@6+ then execute the command for backward compatibility:
npm install --save rxjs-compat@6

Note Sometimes map operator gives an error Property map does not exist on type Observable<Object>

To kick this out, import Observable like this:
import { Observable } from "rxjs/Rx";

And it should work ­čĹŹ Best of luck

More Issues: