类型 'boolean' 不可分配给类型 'CaseReducer<ReportedCasesState, { payload: any; type: string; }> '

Type 'boolean' is not assignable to type 'CaseReducer<ReportedCasesState, { payload: any; type: string; }> '

我使用 redxjs/toolkit 创建了一个删除减速器:

import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { AppThunk } from "../store";
import { ReportedCase, deleteReportCase } from "../../api/reportedCasesApi";
import history from "../../history/history";


interface ReportedCasesState {
  username: string;
  loading: boolean;
  reportedCases: ReportedCase[];
  error: string | null;
}

const initialState: ReportedCasesState = {
  username: 'user',
  loading: false,
  reportedCases: [],
  error: null
}
const reportedCases = createSlice({
  name: 'reportedCase',
  initialState,
  reducers: {
    caseStart: (state) => {
      state.error = null;
    },

    deletedReportedCaseSuccess: (state, action: PayloadAction<number>) => {
      state.reportedCases = state.reportedCases.filter(case => case.id !== action.payload)
    },
   reportCaseError: (state, action: PayloadAction<string>) => {
      state.error = action.payload
    },
})

export const { caseStart,
   } = reportedCases.actions;

export default reportedCases.reducer;


export const deleteReportCase = (id: number): AppThunk => async dispatch => {
  try {
    dispatch(caseStart());
    const deletedReportedCase = await deleteReportCase(id);
    dispatch(reportCaseSuccess(deletedReportedCase))

  } catch (error) {
    let errorMessage = "Internal Server Error";
    if (error.response) {
      errorMessage = error.response.data.message;
    }
    dispatch(reportCaseError(errorMessage))
  }
}

我在打字稿中遇到了这个错误:

Argument expression expected.ts(1135)
Type 'boolean' is not assignable to type 'CaseReducer<ReportedCasesState, { payload: any; type: string; }> | CaseReducerWithPrepare<ReportedCasesState, PayloadAction<any, string, any, any>>'.ts(2322)

这里的问题是,参数名称是 reserved javascript wordcase。我更新了参数名称,它现在可以工作了:

deletedReportedCaseSuccess: (state, action: PayloadAction<number>) => {
      state.reportedCases = state.reportedCases.filter(c => c.id !== action.payload)
    }