CombineLatestWith with pipe operator is ginging error: Property 'pipe' does not exist on type 'OperatorFunction<unknown, []>'

123 views Asked by At

I was using combineLatest in my project which is working fine. But now it got deprecated. So i was looking for alternate solution. I am trying with "combineLatestWith". But it doesn't accept pipe operator and giving below error:

Property 'pipe' does not exist on type 'OperatorFunction<unknown, [unknown, string, number, boolean]>'

Any reason why I am not able to use pipe operator with combineLatestWith?? Below is my code:

    export class TestService implements OnDestroy {
      private _viewName$: BehaviorSubject<string> = new BehaviorSubject<string>('');
      public depth$: BehaviorSubject<number> = new BehaviorSubject<number>(2);
      public graphMode$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
    
      private _loadSubtree$(rootId: string, showGlobalLoadingIndicator: boolean = false): Observable<OprTreeGridItem<CI>[]> {

         //Below line has the error
          return combineLatestWith(this._viewName$, this.depth$, this.graphMode$).pipe(
          tap(() => this._isSubtreeLoading$.next(showGlobalLoadingIndicator)),
          switchMap(([viewName, depth, graphMode]) => this._topViewGraphHttpService.getTopViewGraph(viewName, depth, -1, rootId, null, graphMode).pipe(
            catchError(() => of([]))
          )),
          map((topViewGraphDto: TopViewGraphDTO) => topViewGraphDto.graph),
          withLatestFrom(this._viewName$, this._pickedCis$.pipe(startWith([])), this.includeViewAsRoot$),
          tap(([nodesAndRelationsDto, viewName, pickedCis, includeViewAsRoot]: [TopViewGraphNodesAndRelationsDTO, string, CI[], boolean]) => {
            console.log("something")
          }),
          map(() => {
           // some code
          })
        );
      }
    }
1

There are 1 answers

0
A J On BEST ANSWER

As per the documentation, combineLatestWith is an rxjs/operator function which returns an OperatorFunction and not an Observable

The correct rxjs function that you are probably looking for here is combineLatest which accepts an array of Observables and returns a new Observable