Оператор канала не поддерживается с: Angular [Typescript] - rxjs - ОбъединитьПоследние - PullRequest
0 голосов
/ 11 ноября 2019

Код с проплемом

import { Injectable } from '@angular/core';
import { AccountingTransactionsStoreService } from './accounting-transactions-store.service';
import { GeneralLedgerAccountsStoreService } from './general-ledger-accounts-store.service';
import { distinctUntilChanged, map, combineLatest } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class AccountingReportsStoreService {


  constructor(
    private accountingTransactionsStore: AccountingTransactionsStoreService,
    private   generalLedgerAccountsStore: GeneralLedgerAccountsStoreService) 
    {}

  readonly generalLedgerAccountsTransaction$
    = combineLatest(
      this.accountingTransactionsStore.selectedPeriodAccountingTransactionsFlate$,
      this.generalLedgerAccountsStore.selectedOrganizationGeneralLedgerAccountsTree$)
      .pipe(distinctUntilChanged())
      .pipe(
        map(([transactionsFlat, accountsTree]) => {
          if (transactionsFlat && accountsTree)
            return [];
          else return [];
        })
      )
}

Ошибка

Свойство 'pipe' не существует для типа 'OperatorFunction '.

1 Ответ

0 голосов
/ 11 ноября 2019

Что не так?

import { distinctUntilChanged, map, combineLatest } from 'rxjs/operators';

Почему?

На самом деле Не уверен, но я выгляжу так, как будто речь идет о перегрузках функций fiunction

Обновление от 100 ИнгоBurk

объединяет последние, как оператор, так и функцию, представляющую наблюдаемое множество других. Однако версия оператора устарела. В зависимости от импорта вы получаете один или другой.

Как решить это

импорт объединитьПоследний из 'rxjs' не из 'rxjs / operator'

import { distinctUntilChanged, map } from 'rxjs/operators';
import { combineLatest} from 'rxjs';

Как я нашел решение?

  • удалил импорт rxjs
  • использовал vscode случайно добавил все отсутствующие импорты (я предпочитаю методом проб и ошибок)
  • enter image description here

Что я узнал? есть шаблон?

  • да и нет, это не шаблон, а трюк! ?‍♀️
  • попробуйте удалить импорт
  • и использовать добавьте все отсутствующие импортные данные
  • , затем позвольте VSCode решить, что импортировать
  • , затем просмотрите разницу
  • затем используйте мой jujment.
  • , потому что VSCode имеет больше знаний о моем коде в своей памяти, чем я ?‍♀️
...