Angular 6 ng lint combineLatest is deprecated

Phaze picture Phaze · May 10, 2018 · Viewed 26.6k times · Source

I recently updated from Angular 5 to Angular 6.

I'm getting this warning combineLatest is deprecated: resultSelector no longer supported, pipe to map instead. Rxjs is version 6.1.0, tslint is 5.10.0, Angular CLI is 6.0.0 and Typescript 2.7.2. I'm using it like this:

const a$ = combineLatest(
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl),
  (auth, url) => ({auth, url}),
);

I've tried it also like this:

empty().pipe(
combineLatest(...),
  ...
)

But this gives me: combineLatest is deprecated: Deprecated in favor of static combineLatest and empty is also deprecated in favor of its static version.

Answer

Abinesh Devadas picture Abinesh Devadas · May 10, 2018

combineLatest is deprecated: resultSelector no longer supported, pipe to map instead

The above warning is recommending to remove the resultSelector the last function you provided in combineLatest observable and provide it as part of map operator as follows

const a$ = combineLatest(
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl)
);

const result$ = a$.pipe(
  map(results => ({auth: results[0], url: results[1]}))
)

UPDATE:

If you see combineLatest is deprecated: Pass arguments in a single array instead then just add []:

const a$ = combineLatest([
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl)
]);
    
const result$ = a$.pipe(
  map(results => ({auth: results[0], url: results[1]}))
)