Problem
Write a generic function that deeply flattens a nested array of any depth. Type it correctly with TypeScript generics.
Test Cases
Deeply nested
Input: [1,[2,[3,[4]],5]]
Expected: [1,2,3,4,5]
Mixed depth
Input: [[1,2],[3,[4,5]]]
Expected: [1,2,3,4,5]
Already flat
Input: [1,2,3]
Expected: [1,2,3]