Issue
I'm using react-redux with typescript and when I define a reducer inside a Slice VSCode shows this error even though it compiles and everything works.
Here's the full code:
//counterSlice.ts
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
export interface CounterState {
  value: number
}
const initialState: CounterState = {
  value: 0
}
export const counterSlice = createSlice({
  name: 'counter',
  initialState,
  reducers: {
    incrementByAmount: (state, action: PayloadAction<number>) => {
      state.value += action.payload
    }
  }
})
export const { incrementByAmount } = counterSlice.actions
export default counterSlice.reducer
                            Solution
SOLVED
Reinstalling the packages with npm solved the problem.
Answered By - remarcoble

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.