alphapilgrim
alphapilgrim

Reputation: 3975

rxjs 6 Property 'of' does not exist on type 'typeof Observable'

Just moved from rxjs 5/angular 5 to rxjs 6/ angular 6, went through this migration-guide. Can't seem to figure out what it should be now, any help appreciated.

import { Observable, of } from 'rxjs';
[ts] 'of' is declared but its value is never read.

// trivial example of what im trying to replace
  isLoggedIn(): Observable<boolean> {
    return Observable.of(true);
  }

Upvotes: 21

Views: 18174

Answers (2)

Mohammad Aljunde
Mohammad Aljunde

Reputation: 71

If you are using Angular 6 /7 or 9

import { of } from 'rxjs';

And then instead of calling

Observable.of(res);

just use

of(res);

Upvotes: 7

MichaelSolati
MichaelSolati

Reputation: 2872

You can now just import of from rxjs. So....

import { Observable, of } from 'rxjs';

// trivial example of what im trying to replace
  isLoggedIn(): Observable<boolean> {
    return of(true);
  }

Upvotes: 34

Related Questions