Currently delving into TypeScript and encountering an issue while setting a reducer in redux Toolkit. Here's the code snippet in question:
const testSlice = createSlice({
name: "test",
initialState: [],
reducers: {
callApi: (state, action) => {
const getData = {
type: "test/getData",
data: action.payload
};
state.push(getData);
}
}
});
Observing that state.push(getData)
is underlined in red within VSCode, displaying the error message:
Argument of type 'any' is not assignable to parameter of type 'never'
Attempted to declare const getData : any[] = {
, but the same error persists.
Seeking guidance on identifying the mistake made. Appreciate any assistance!