mergeMap does not exist on type observable

prolink007 picture prolink007 · May 2, 2018 · Viewed 10.9k times · Source

I am trying to use mergeMap in rxjs6 and i am getting this error:

Property 'mergeMap' does not exist on type 'Observable<{}>'

I have tried import 'rxjs/add/operator/mergeMap'; and it is not working.

What am i doing wrong?


import {from, Observable} from 'rxjs';

export class Test {

    public doSomething(): Observable<any> {
        return from(...).mergeMap();
    }

}

Answer

martin picture martin · May 2, 2018

That's correct, the "patch" style of operators has been removed since RxJS 6. You should better update your code to use only "pipeable" operators or install rxjs-compat package that provides backwards compatibility with RxJS 5.

For more detailed description see official doc: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md

... more specifically this part: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#backwards-compatibility