Я пытаюсь разработать приложение, используя ngrx/store
, получаю ошибку.не в состоянии выяснить проблему.кто-нибудь мне помочь?
вот мои ошибки:
ERROR in src/app/store/effects/authentication.effects.ts(25,7): error TS2339: Property 'ofType' does not exist on type 'Actions<Action>'.
src/app/store/effects/authentication.effects.ts(29,59): error TS2339: Property 'email' does not exist on type '{}'.
src/app/store/effects/authentication.effects.ts(29,74): error TS2339: Property 'password' does not exist on type '{}'.
src/app/store/effects/authentication.effects.ts(33,73): error TS2339: Property 'email' does not exist on type '{}'.
машинописный файл:
import { Injectable } from '@angular/core';
import { Action } from '@ngrx/store';
import { Router } from '@angular/router';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Observable, of } from 'rxjs';
import { map, switchMap, catchError, tap } from 'rxjs/operators';
import { AuthenticationService } from './../../service/authentication.service';
import { AuthenticationActionTypes,
Login, LoginSuccess,
LoginFailure, Logout } from './../actions/authentication.actions';
@Injectable({
providedIn: 'root'
})
export class AuthenticationEffects {
constructor(
private actions:Actions,
private authenticationService:AuthenticationService,
private router:Router) {}
@Effect()
Login: Observable<any> = this.actions
.ofType(AuthenticationActionTypes.LOGIN)
.pipe(
map((action: Login) => action.payload),
switchMap(payload => {
return this.authenticationService.login(payload.email, payload.password)
.pipe(
map((user) => {
console.log(user);
return new LoginSuccess({token: user.token, email: payload.email});
}),
catchError((error) => {
return of(new LoginFailure({ error: error }));
}));
}));
@Effect({ dispatch: false })
LoginSuccess: Observable<any> = this.actions.pipe(
ofType(AuthenticationActionTypes.LOGIN_SUCCESS),
tap((user) => {
localStorage.setItem('token', user.payload.token);
localStorage.setItem('email', user.payload.email);
this.router.navigateByUrl('/');
})
);
@Effect({ dispatch: false })
LoginFailure: Observable<any> = this.actions.pipe(
ofType(AuthenticationActionTypes.LOGIN_FAILURE)
);
@Effect({ dispatch: false })
public Logout: Observable<any> = this.actions.pipe(
ofType(AuthenticationActionTypes.LOGOUT),
tap((user) => {
localStorage.removeItem('token');
localStorage.removeItem('email');
this.router.navigateByUrl('/login');
})
);
}
JSON файл:
{
"name": "authentication",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^7.0.0",
"@ngrx/store": "^7.0.0",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.12.0",
"@angular/cli": "~7.2.2",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"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",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
любойпомогите мне здесь ... спасибо заранее.