```typescript
/**
 * Returns the smallest list of non-overlapping pairs covering the same points,
 * sorted ascending by start. Intervals that merely touch (end === next start) do merge.
 *
 * @param intervals A list of [start, end] pairs
 */
export function mergeIntervals(intervals: number[][]): number[][] {
    // Check if all intervals are valid
    for (const interval of intervals) {
        if (interval[0] > interval[1]) {
            throw new Error("Interval cannot have a start greater than its end");
        }
    }

    // Sort the intervals by start time
    intervals.sort((a, b) => a[0] - b[0]);

    // Initialize the result with the first interval
    const merged: number[][] = [intervals[0]];

    // Iterate over the remaining intervals
    for (const current of intervals.slice(1)) {
        // Get the last merged interval
        const lastMerged = merged[merged.length - 1];

        // Check if the current interval overlaps with the last merged interval
        if (current[0] <= lastMerged[1]) {
            // Merge the two intervals by updating the end time of the last merged interval
            lastMerged[1] = Math.max(lastMerged[1], current[1]);
        } else {
            // Add the current interval to the result
            merged.push(current);
        }
    }

    return merged;
}
```