Search code examples
angularrxjsngrxangular10angular-upgrade

After Migrating to Angular 10, I am getting error - error TS2339: Property 'ofType' does not exist on type 'Actions<Action>'


Error Message -

ERROR in src/app/store/effects/cuser.effects.ts:31:32 - error TS2339: Property 'ofType' does not exist on type 'Actions'.

loadCuser$ = this.actions$.ofType( fromCuser.LOAD_CUSER ).pipe(

Code Snipet

@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}`) ) ;

My 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"
  }
}

Can someone please guide to solve this issue. Is it some library issue or version incompatibility error .


Solution

  • Your NGRX version is 10

    Please check the migration docs from v7.

    ofType is now a pipeable operator so correct use is now:

    https://ngrx.io/guide/migration/v7

     this.actions$.pipe(
        ofType(fromCuser.LOAD_CUSER),
        ...