[英]Typescript shows an error even though it compiles on VSCode
我将 react-redux 与 typescript 一起使用,当我在 Slice 中定义减速器时,VSCode 显示此错误,即使它可以编译并且一切正常。
这是完整的代码:
//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
用npm
重新安装软件包解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.