属性"管道"在类型"操作"上不存在<Action>



我注意到问题 #990 但没有解决方案。

项目正在编译,但是当我尝试将 .pipe 与商店一起使用时,我收到一个 linting 错误,指出我的效果和组件中的"操作"类型上不存在属性"管道"。但是,当我在可观察对象上使用 .pipe 时,我在同一组件中没有遇到问题。

类型存储/操作上不存在 Linting 问题示例

this.item$ = this.store.pipe(select(item));
@Effect({ dispatch: false })
logout$ = this.actions$.pipe(
ofType<Logout>(AuthActionTypes.LogoutAction),
tap(() => {
localStorage.removeItem(USER);
this.router.navigate(['/']);
})
);

没有问题

this.item$.pipe(takeUntil(this.onDestroy$)).subscribe(status => {

Package.json 这是带有 rxjs 6 和 NgRx 库的 Angular 6

"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.5",
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"@ngrx/effects": "^6.1.0",
"@ngrx/entity": "^6.1.0",
"@ngrx/router-store": "^6.1.0",
"@ngrx/store": "^6.1.0",
"@ngrx/store-devtools": "^6.1.0",
"core-js": "^2.5.4",
"rxjs": "~6.2.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.4",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@ngrx/schematics": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ngrx-store-freeze": "^0.2.4",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
}

有同样的错误。就我而言,这是因为我从"@ngrx/store-devtools/src/reducer"而不是"@ngrx/效果"导入操作

import { Injectable } from '@angular/core';
import { createEffect } from '@ngrx/effects';
//import { Actions } from '@ngrx/store-devtools/src/reducer'; --> wrong
import { Actions, ofType } from '@ngrx/effects';
import { map, mergeMap } from 'rxjs/operators';
import { ProductService } from '../product.service';
import * as ProductActions from './product.actions';
@Injectable()
export class ProductEffects {
constructor(private actions$: Actions,
private productsService: ProductService) { }

loadProducts$ = createEffect(() => {
return this.actions$.pipe(
ofType(ProductActions.loadProducts),
mergeMap(() => this.productsService.getProducts().pipe(
map(products => ProductActions.loadProductsSuccess({ products }))
))
)
})

}

相关内容

最新更新