迁移到 Angular 10 后,出现错误 - 错误 TS2339:属性 'ofType' 在类型 'Actions<Action>' 上不存在
After Migrating to Angular 10, I am getting error - error TS2339: Property 'ofType' does not exist on type 'Actions<Action>'
错误信息-
src/app/store/effects/cuser.effects.ts:31:32 中的错误 - 错误 TS2339:属性 'ofType' 在类型 'Actions'.[=17 上不存在=]
loadCuser$ = this.actions$.ofType( fromCuser.LOAD_CUSER ).pipe(
代码片段
@Effect()
loadCuser$ = this.actions$.ofType( fromCuser.LOAD_CUSER ).pipe(
switchMap( (action: any) => this.serv.getCurrentUser() ))
.map( r => {
//.... rest of my code
}).catch( error => of(`Bad Promise: ${error}`) ) ;
我的Package.json
{
"name": "ng4",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/schematics": "0.0.34",
"@angular/animations": "9.1.13",
"@angular/cdk": "^10.2.7",
"@angular/common": "10.2.5",
"@angular/compiler": "10.2.5",
"@angular/core": "10.2.5",
"@angular/forms": "^10.2.5",
"@angular/http": "4.4.5",
"@angular/platform-browser": "^10.2.5",
"@angular/platform-browser-dynamic": "9.1.13",
"@angular/router": "9.1.13",
"@ngrx/core": "1.2.0",
"@ngrx/effects": "^10.1.2",
"@ngrx/store": "^10.1.2",
"@types/lodash": "4.14.85",
"angular-sanitize": "^1.8.0",
"bootstrap": "^3.4.1",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"decode-html": "^2.0.0",
"font-awesome": "4.7.0",
"immutable": "3.8.2",
"jquery": "3.2.1",
"lodash": "4.17.4",
"moment": "2.20.1",
"ngx-bootstrap": "^6.2.0",
"ngx-logger": "^4.2.1",
"rxjs": "6.6.2",
"rxjs-compat": "^6.6.7",
"tslib": "^2.0.0",
"zone.js": "^0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1002.3",
"@angular/cli": "^10.2.3",
"@angular/compiler-cli": "10.2.5",
"@angular/language-service": "10.2.5",
"@types/jasmine": "2.5.53",
"@types/jasminewd2": "2.0.2",
"@types/jquery": "3.2.16",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "3.2.0",
"tslint": "~6.1.0",
"typescript": "^3.9.2"
}
}
谁能指导一下解决这个问题。是库问题还是版本不兼容错误。
您的 NGRX 版本是 10
请查看 v7 的迁移文档。
ofType
现在是可管道运算符,因此现在正确使用是:
https://ngrx.io/guide/migration/v7
this.actions$.pipe(
ofType(fromCuser.LOAD_CUSER),
...
错误信息-
src/app/store/effects/cuser.effects.ts:31:32 中的错误 - 错误 TS2339:属性 'ofType' 在类型 'Actions'.[=17 上不存在=]
loadCuser$ = this.actions$.ofType( fromCuser.LOAD_CUSER ).pipe(
代码片段
@Effect()
loadCuser$ = this.actions$.ofType( fromCuser.LOAD_CUSER ).pipe(
switchMap( (action: any) => this.serv.getCurrentUser() ))
.map( r => {
//.... rest of my code
}).catch( error => of(`Bad Promise: ${error}`) ) ;
我的Package.json
{
"name": "ng4",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/schematics": "0.0.34",
"@angular/animations": "9.1.13",
"@angular/cdk": "^10.2.7",
"@angular/common": "10.2.5",
"@angular/compiler": "10.2.5",
"@angular/core": "10.2.5",
"@angular/forms": "^10.2.5",
"@angular/http": "4.4.5",
"@angular/platform-browser": "^10.2.5",
"@angular/platform-browser-dynamic": "9.1.13",
"@angular/router": "9.1.13",
"@ngrx/core": "1.2.0",
"@ngrx/effects": "^10.1.2",
"@ngrx/store": "^10.1.2",
"@types/lodash": "4.14.85",
"angular-sanitize": "^1.8.0",
"bootstrap": "^3.4.1",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"decode-html": "^2.0.0",
"font-awesome": "4.7.0",
"immutable": "3.8.2",
"jquery": "3.2.1",
"lodash": "4.17.4",
"moment": "2.20.1",
"ngx-bootstrap": "^6.2.0",
"ngx-logger": "^4.2.1",
"rxjs": "6.6.2",
"rxjs-compat": "^6.6.7",
"tslib": "^2.0.0",
"zone.js": "^0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1002.3",
"@angular/cli": "^10.2.3",
"@angular/compiler-cli": "10.2.5",
"@angular/language-service": "10.2.5",
"@types/jasmine": "2.5.53",
"@types/jasminewd2": "2.0.2",
"@types/jquery": "3.2.16",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "3.2.0",
"tslint": "~6.1.0",
"typescript": "^3.9.2"
}
}
谁能指导一下解决这个问题。是库问题还是版本不兼容错误。
您的 NGRX 版本是 10
请查看 v7 的迁移文档。
ofType
现在是可管道运算符,因此现在正确使用是:
https://ngrx.io/guide/migration/v7
this.actions$.pipe(
ofType(fromCuser.LOAD_CUSER),
...