I am searching for a solution in TypeScript that adds an element to the beginning of an array and returns the updated array. I am working with Angular and Redux, trying to write a reducer function that requires this specific functionality. Using unshift doesn't return the array, and even using splice(0, 0, newObject) is not successful. Can anyone suggest another approach? The concat method does work but adds the element to the end of the array.
function Addrow(state: State, action: any): State {
return Object.assign({}, state,{
displayCodes: { list: copyobject.list.concat(state.displayCodes.list.length)},
filteredCodes: { list: copyobject.list.concat(state.displayCodes.list.length)}
});