gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 09:44:23 24 4
gpt4 key购买 nike

我已经使用新的 更新了在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com