Аргумент типа не может быть назначен параметру типа 'OperatorFunction ' - PullRequest
0 голосов
/ 12 апреля 2020

Я недавно обновился до Angular 9 и продолжаю получать эту ошибку в моем файле user.effects.ts:

ERROR in src/app/modules/core/store/user/user.effects.ts:30:9 - error TS2345: Argument of type 'OperatorFunction<IUser, { payload: Partial<IUser>; } & TypedAction<"[Use
r] Data Received">>' is not assignable to parameter of type 'OperatorFunction<unknown[], { payload: Partial<IUser>; } & TypedAction<"[User] Data Received">>'.
  Type 'IUser' is missing the following properties from type 'unknown[]': length, pop, push, concat, and 26 more.

30         map(
           ~~~~
31           (data: IUser) => UserActions.dataReceived({ payload: UserService.parseData(data) })
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32         )

Мой код выглядит следующим образом:

  @Effect()
  getData$ = this.actions$.pipe(
    ofType(UserActions.getData),
    switchMap(() => {
      return this.userService.getUserById(localStorage.getItem('uid')).pipe(
        map(
          (data: IUser) => UserActions.dataReceived({ payload: UserService.parseData(data) })
        )
      );
    })
  );

1 Ответ

1 голос
/ 12 апреля 2020

Ваш код должен быть

new UserActions.dataReceived({ payload: UserService.parseData(data) })

Дайте мне знать, если у вас все еще есть проблемы

...