3 ms·
Concat doesn't mutate the original array, so there is no reason the output has to have the same value as the original array. Typescript has chosen to implement
by underwater 8y ago
Concat doesn't mutate the original array, so there is no reason the output has to have the same value as the original array. Typescript has chosen to implement it this way, but it's not a limitation of the underlying JS method. Saying it's wrong because it's how Typescript has typed the function is circular reasoning.
Consider the same functionality exposed as a function, it would seem be fine to type this as:
function concat(a: Array<A>, b: Array<B>): Array<A | B> { }