0

I'm migrating my app from Angular 5.2.9 to Angular 6.0.4

I ve upgraded from rxjs v5 to v6 And I've uninstalled : rxjs-compat (as I was told that it's no more needed)

So in the old syntax, I was used to return custom observable like this:

  public myObservable() {
    return Observable.of(true);
  }

It seems that this syntax is no more usefull as there is no more the operator "of"

the error is the following:

error TS2339: Property 'of' does not exist on type 'typeof Observable'.

So what is the alternative? Suggestions?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
firasKoubaa
  • 6,439
  • 25
  • 79
  • 148

2 Answers2

1

You just need to directly import it from rxjs.

import { of } from 'rxjs';
Teddy Sterne
  • 13,774
  • 2
  • 46
  • 51
0

You should import of operator separately, like this:

import 'rxjs/add/observable/of';
P.S.
  • 15,970
  • 14
  • 62
  • 86