error TS2304: Cannot find name 'Observable' Angularjs 2 error TS2304: Cannot find name 'Observable' Angularjs 2 typescript typescript

error TS2304: Cannot find name 'Observable' Angularjs 2


I had the same issue fixed it by importing Observable

import {Observable} from 'rxjs/Rx';


You can do it in 2 ways

1. Import Observable and then import other functions like map, do, catch, throw whichever you are using

import {Observable} from 'rxjs/Observable';import 'rxjs/add/operator/map';import 'rxjs/add/operator/catch';..........import 'rxjs/add/observable/throw';

2. Importing whole Rxjs

import {Observable} from 'rxjs/Rx';

or

import {Observable} from 'rxjs';

Its recommended to use first method, since importing whole rxjs is not necessary and will include all the sub-modules into the bundle affecting bundle size and load time


None of the solutions worked, I had to use

import { Observable } from 'rxjs';