NgRx Effects 抛出类型错误,我不知道发生了什么

问题描述 投票:0回答:0

我试图创建一个常量来放置所有动作但是当我实现它时我得到了他的错误:

Argument of type 'OperatorFunction<Action, Action>' is not assignable to parameter of type 'OperatorFunction<Action, { pageSize: number; pageIndex: number; }>'. Type 'Action' is missing the following properties from type '{ pageSize: number; pageIndex: number; }': pageSize, pageIndex

之前(工作正常):

paginateStudents$ = createEffect(()=>this.actions$.pipe(
        ofType('[Student List] Paginate students'),
        mergeMap((action: {pageSize: number; pageIndex: number})=> this.studentService.getAll(action.pageSize,action.pageIndex)
        .pipe(
            map((students: StudentResponse) => ({type: ACTIONS.PAGINATE_STUDENTS_SUCCESS, payload:{
                studentList: students.data,
                pageSize: students.pageSize
            }})),
            catchError(()=> EMPTY)
        ))
    ));

之后(不起作用):

paginateStudents$ = createEffect(()=>this.actions$.pipe(
        ofType(ACTIONS.PAGINATE_STUDENTS),
        mergeMap((action: {pageSize: number; pageIndex: number})=> this.studentService.getAll(action.pageSize,action.pageIndex)
        .pipe(
            map((students: StudentResponse) => ({type: ACTIONS.PAGINATE_STUDENTS_SUCCESS, payload:{
                studentList: students.data,
                pageSize: students.pageSize
            }})),
            catchError(()=> EMPTY)
        ))
    ));

常量动作列表:

export const ACTIONS = {
    ...
    PAGINATE_STUDENTS: '[Student List] Paginate students',
    ...
}

student.action:

export const paginatedStudents = createAction(
    ACTIONS.PAGINATE_STUDENTS_SUCCESS,
    props<{
        payload: {
            studentList: readonly Student[];
            pageSize: number
        }
    }>()
);
angular ngrx ngrx-effects
© www.soinside.com 2019 - 2024. All rights reserved.