example returns { Array } export function removeIndexFromArray < T extends any [ ] > ( array , index ) { if ( index === - 1 ) return array ; return [ ... array . slice ( 0 , index ) , ... array . slice ( index + 1 ) ] as T ; }