Rxjs: Incorrect merge deprecation warning when used with Angular events

Created on 8 Oct 2019  Â·  3Comments  Â·  Source: ReactiveX/rxjs

Bug Report

Current Behavior
Consider an Angular project with the following code:

app.component.ts:

import { Router } from '@angular/router';
import { merge, of } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent {

  constructor(router: Router) {
    merge(
      of(null),
      router.events
    );
  }
}

Running the linter within the Angular CLI project with the command ng lint, the following warning is thrown:

WARNING: /code/src/app/app.component.ts:13:5 - merge is deprecated: use {@link scheduled} and {@link mergeAll} (e.g. `scheduled([ob1, ob2, ob3], scheduled).pipe(mergeAll())

Reproduction

  1. Within a fresh Angular CLI project, copy/paste the code shown above into app.component.ts.
  2. In the terminal, run ng lint

Expected behavior
No deprecation warning for static merge function with two argument Observables.

Environment

> ng "version"


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.6
Node: 10.16.0
OS: linux x64
Angular: 8.2.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.802.2
@angular-devkit/build-angular      0.802.2
@angular-devkit/build-ng-packagr   0.802.2
@angular-devkit/build-optimizer    0.802.2
@angular-devkit/build-webpack      0.802.2
@angular-devkit/core               8.2.2
@angular-devkit/schematics         8.3.6
@angular/cli                       8.3.6
@ngtools/webpack                   8.2.2
@schematics/angular                8.3.6
@schematics/update                 0.803.6
ng-packagr                         5.5.1
rxjs                               6.5.3
typescript                         3.5.3
webpack                            4.38.0

Additional context/Screenshots

I noticed that if I make the router.events the first argument, then no deprecation warning is thrown while linting:

merge(
  router.events,
  of(null) );
)
TS types

Most helpful comment

I just discovered the same issue with the following code snippet:

import { FormControl } from '@angular/forms';
import { merge } from 'rxjs';

const control = new FormControl();
merge(
  control.statusChanges,
  control.valueChanges
);

Workaround:

const control = new FormControl();
merge(...[
  control.statusChanges,
  control.valueChanges
]);

All 3 comments

I just discovered the same issue with the following code snippet:

import { FormControl } from '@angular/forms';
import { merge } from 'rxjs';

const control = new FormControl();
merge(
  control.statusChanges,
  control.valueChanges
);

Workaround:

const control = new FormControl();
merge(...[
  control.statusChanges,
  control.valueChanges
]);

Same here... Seems kind of weird resolving the problem with a workaround @samherrmann suggested (however it works, thanks).

Even with @samherrmann workaround I still get the deprecated symbol in Webstorm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Agraphie picture Agraphie  Â·  3Comments

chalin picture chalin  Â·  4Comments

benlesh picture benlesh  Â·  3Comments

LittleFox94 picture LittleFox94  Â·  3Comments

matthewwithanm picture matthewwithanm  Â·  4Comments