Closed jerome-benoit closed 2 years ago
Hello @jerome-benoit. While I see the obvious reason why this would be better, your PR introduce a type error because the array returned might be from a different class, based on the array constructor that was (sometimes optionally) passed to the structure as argument to shape the underlying storage. So I guess the best way here would be to introduce an optional generic to type this, but I see how this could be cumbersome and I am wondering whether we could find a better solution that does not end up in information erasure through Array<T>
.
Other array types are still array. The best way is to use or
in the type: Array<T> | Uint8Array | Uint16Array | Uin32Array | ...
or a typeof
cast
Thanks @jerome-benoit. I will merge now. I think we can find a better way through generics but I can't find a way not to bother the user with it so type inference works properly so your solution is a good tradeoff for now I think.
Published in v0.39.2 on npm
Signed-off-by: Jérôme Benoit jerome.benoit@piment-noir.org