Hacker News new | ask | show | jobs
by ekvintroj 1155 days ago
Try to type a flatMap and then we talk.
2 comments

    type ValueOrArray<T> = T | Array<ValueOrArray<T>>;
    type FlatMap<In, Out> = (array: Array<In>, fn: (el: In) => ValueOrArray<Out>) => Array<Out>;
This does not work, that's the issue, try to run it.
It seems to work for me, what issue are you seeing?

https://www.typescriptlang.org/play?target=6#code/C4TwDgpgBA...

Is this actually an issue?