```ts
function mergeIntervals(intervals: number[][]): number[][] {
    // Guard clauses to ensure valid intervals
    if (!intervals || intervals.length === 0) return [];

    const sorted = intervals.sort((a, b) => a[0] - b[0]);   // Sort by start point

    let result: any[] [] = [];                                  // Container for the merged output

    let current = sorted[0];                                       // Start with the first interval

    for (let i = 1; i < sorted.length; i++) {
        const interval = sorted[i];
        if (interval[0] <= current[1]) {                            // Check overlap, extend previous's end
            current[1] = Math.max(current[1], interval[1]);         // Update the maximum of previous end and current end
        } else {
            result.push([...current]);                          // Output a new pair because of isolation
            current = interval;                                    // Update to current interval to avoid overlapping
        }
    }

    result.push([...current]);                                   // Push last interval

    return result.map(arr => arr as number[][]);               // Assert that elements type is correct and cast
}
```