Observable.of is not a function Observable.of is not a function angular angular

Observable.of is not a function


Actually I have imports messed up. In latest version of RxJS we can import it like that:

import 'rxjs/add/observable/of';


If anybody is having this problem while using Angular >= 6 and rxjs version 6 or greater, see the answers here:Could not use Observable.of in RxJs 6 and Angular 6

In short, you need to import it like this:

import { of } from 'rxjs';

And then instead of calling

Observable.of(res);

just use

of(res);


Although it sounds absolutely strange, with me it mattered to capitalize the 'O' in the import path of import {Observable} from 'rxjs/Observable. The error message with observable_1.Observable.of is not a function stays present if I import the Observable from rxjs/observable. Strange but I hope it helps others.