angular6 - Angular v6、rxjs v6 错误 TS2339 : Property 'pipe' does not exist on type 'OperatorFunction

标签 angular6 rxjs6

我已经使用新的 更新了在 Angular 5.5/rxJS5.5 中运行良好的代码管道 使用 rxjs-lint 包和以下命令对 Angular 6/rxJS6 的方法

npm i -g rxjs-tslint
rxjs-5-to-6-migrate -p tsconfig.json

导入等已按预期进行了修改,但现在与 RxJS 的 Angular/5.5 的 v5 一起正常工作的代码出现错误:
 error TS2339: Property 'pipe' does not exist on type 'OperatorFunction<{}, {} | RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivati...'.

我已经删除了 rxjs6-compat 包,但它没有区别。几乎就好像构建认为它拥有比 v5.5 更早的 rxJS 版本。 package.json 与 npm install 一起使用看起来像这样......
"dependencies": {
    "@angular/animations": "^6.0.2",
    "@angular/cdk": "^6.0.2",
    "@angular/common": "^6.0.2",
    "@angular/compiler": "^6.0.2",
    "@angular/core": "^6.0.2",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "^6.0.2",
    "@angular/http": "^6.0.2",
    "@angular/material": "^6.0.2",
    "@angular/platform-browser": "^6.0.2",
    "@angular/platform-browser-dynamic": "^6.0.2",
    "@angular/router": "^6.0.2",
    "@ngrx/effects": "^6.0.0-beta.3",
    "@ngrx/entity": "^6.0.0-beta.3",
    "@ngrx/router-store": "^6.0.0-beta.3",
    "@ngrx/store": "^6.0.0-beta.3",
    "@ngrx/store-devtools": "^6.0.0-beta.3",
    "@ngx-translate/core": "^9.0.1",
    "core-js": "^2.5.2",
    "hammerjs": "^2.0.8",
    "lodash": "^4.17.4",
    "material-design-icons-iconfont": "^3.0.3",
    "nsp": "^3.2.1",
    "passport": "^0.4.0",
    "passport-azure-ad": "^3.0.12",
    "rxjs": "^6.1.0",
    "zone.js": "^0.8.26"
  },

rxjs 运算符的导入采用 rxjs6 格式:
import { filter, map, merge, mergeMap } from 'rxjs/operators';

有效但现在出现此错误的语句是:
// Change page title on navigation or language change, based on route data
merge(this.translateService.onLangChange, onNavigationEnd)
  .pipe(
    map(() => {
      let route = this.activatedRoute;
      while (route.firstChild) {
        route = route.firstChild;
      }
      return route;
    }),
    filter(route => route.outlet === 'primary'),
    mergeMap(route => route.data)
  )
  .subscribe(event => {
    const title = event['title'];
    if (title) {
      this.titleService.setTitle(this.translateService.instant(title));
    }
  });

我错过了什么?为什么现在管道会在 rxJS 5.5 正常的情况下导致此错误?

最佳答案

您应该像这样导入合并:

import { merge } from 'rxjs';

关于angular6 - Angular v6、rxjs v6 错误 TS2339 : Property 'pipe' does not exist on type 'OperatorFunction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50413038/

相关文章:

javascript - 如何使用 rxjs 的 sum 运算符?

RxJS 从 mergeMap 返回值数组

javascript - Angular 2+ 检测服务内部的对象属性更改

html - 如何覆盖 Bootstrap 中主按钮的样式

javascript - 拦截器 Angular 6 中的刷新 token (JWT)

angular - 在 Rxjs 中使用 mergeMap 时未定义的输出

angular - 响应式(Reactive)表单自定义验证器不显示 Angular6 中的错误

angular - 我如何使用 Angular Material 从服务中显示 MatSnackBar?

angular - ng 测试给出组件应该创建

Angular 6 管道操作从可观察中删除类型