Necesito definir en el estado de mi aplicación como matriz vacía inicialmente y luego será una matriz de objetos.
Tengo el tipo de objeto definido como a continuación:
export type LuxmedBenefitUserType= { id: number; name: string; lastName: string; profileName: string; contractForm: string; userRelation: string; offerType: string; totalPrice: number; employerCost: number; employeeCost: number; };Luego defino el estado inicial de createSlice como se muestra a continuación.
export const addEditLuxmedBenefitSystemsSlice = createSlice({ name: 'addEditLuxmedSlice', initialState: [] as LuxmedBenefitUserType[], reducers: { addEditBenefits: (state, action) => { const {id} = action.payload; if(!state) {state.push(action.payload)}; if(state) {state.map = (user)=>{ user.id === id && return action.payload }}; }, }, });Pero con esto no puedo continuar con .push, me arroja un error:
any Property 'push' does not exist on type 'never'.¿Puede decirme qué hago mal aquí y ese estado me permitirá usar el método .push?
Gracias