TypeScript Max Slice Sum
function maxSliceSum(a: number[]): number {
  let tmp = -Infinity;
  let max = -Infinity;

  for (const v of a) {
    tmp = Math.max(tmp + v, v);
    max = Math.max(max, tmp);
  }

  return max;
}

This is a Kadane-style scan: keep the best running sum and the best overall sum while moving once through the array.