Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Notably, the provided type for Array.prototype.flat doesn't actually provide the flat type for arrays of a known structure.

In other words, if you flatten `[string, [string, number]]` my example would give you `[string, string, number]` whereas the one in lib.es2019.array.d.ts would give you `(string | number)[]`

(my example, on the other hand, would only flatten a depth of 1, though a completely flattened type instead of just depth 1 could be represented by changing `[...First, ...FlatArr<Rest>] :` to `[...FlatArr<First>, ...FlatArr<Rest>] :`

I haven't tried supporting a depth param, but I suspect it's possible.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: