20985

Angular 6 ng lint combineLatest is deprecated

Question:

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.

Answer1:

<blockquote>

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

</blockquote>

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]})) )

Answer2:

Unfortunately you might also get that tslint error if you import combineLatest from operators:

import { combineLatest } from 'rxjs/operators'; combineLatest(...array);

instead of,

import { combineLatest } from 'rxjs'; combineLatest(...array);

Answer3:

For trailing comma error, remove the comma after (auth, url) => ({auth, url})

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

For missing import error, Make sure you have imports for all the external var's or classes you are using in the file.

Example, in this case, if you havent imported combineLatest, then import it

import { combineLatest } from 'rxjs'; // For RxJS 6.x import { combineLatest } from 'rxjs/operators'; // For RxJS 5.x

Recommend

  • spring mvc get mapping controller method from interceptor
  • Trouble fetching some title from a webpage
  • R: Easy assignments with empty square brackets? x[]
  • Query was empty Nodejs Sequlize
  • Inter portlet communication in liferay
  • Remove unneeded Woocommerce image meta
  • Why do I get IPC delays on 20% busy machine
  • How to fit a-plane to the a-canvas
  • How to test Rate this app functionality before submitting to app store
  • Changing UITableViewCell's width constraint's constant value for each instance
  • Equivalent of window.locaton and window.pathname in NodeJS
  • Get all the values from excel file by using linqtoexcel
  • How do I send Email with inline Attachments
  • Decompress string in java from compressed string in C#
  • How to add tag during runtime in C#
  • Existing data serialized as hash produces error when upgrading to Rails 5
  • DocuSign API Replace template document but keep fields
  • Firebase suddenly reports invalid signature
  • How to delete first 7 characters of folder name by using batch script?
  • Python sum values in tuple in a list in a dictionary?
  • $this->a->b->c->d calling methods from a superclass in php
  • How to create OLE Automation to be used with ClearExplorer
  • Boolean filter using a timestamp value on a dataframe in Python
  • css: column-count 3, image floating spanning 2, chrome not playing. why?
  • What is the difference between dynamically creating a script tag and statically embed a script tag?
  • Regex not working in java 1.5
  • Using redis as an LRU cache for postgres
  • Google App Engine Datastore: Dealing with eventual consistency
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • Update cell query for Excel ADO from Delphi
  • Why my AngularJS async test in Jasmine 1.3.x is not working?
  • How to call different template for different category archive page in woocommerce
  • customize soft keyboard key preview
  • Using Service Component Runtime
  • How to use FirstOrDefault inside Include
  • PHP Permalinks.. how to change?
  • media foundation H264 decoder not working properly
  • Running R's aov() mixed effects model from Python using rpy2
  • Access to a Matlab gui from the web