期望赋值或函数调用,而是看到表达式 @typescript-eslint/no-unused-expressions
Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions
我正在尝试为我的 Redux 应用程序创建一个 reducer,但以下代码不断出现此错误
期望赋值或函数调用,却看到表达式 @typescript-eslint/no-unused-expressions
const reducer = combineReducers({
answers: (state:string[] = [], action) => {
const newState:string[] = state
if(action.type == "add") {
newState.push(action.item)
}
if(action.type == "reset"){
newState == [];
}
console.log(newState)
return newState
}
})
我已经在返回一个值 (newState),所以我不确定我做错了什么
newState == []
是条件,不是赋值
我正在尝试为我的 Redux 应用程序创建一个 reducer,但以下代码不断出现此错误
期望赋值或函数调用,却看到表达式 @typescript-eslint/no-unused-expressions
const reducer = combineReducers({
answers: (state:string[] = [], action) => {
const newState:string[] = state
if(action.type == "add") {
newState.push(action.item)
}
if(action.type == "reset"){
newState == [];
}
console.log(newState)
return newState
}
})
我已经在返回一个值 (newState),所以我不确定我做错了什么
newState == []
是条件,不是赋值