feat: make result of StaticArray#slice and StaticArray#concat as instance generics. Deprecate static methods#2404
Conversation
|
Iirc the idea here is that |
|
The main problem with |
|
I guess the same would apply to other static methods as well then, and without inference of return types seems tricky. Hmm. Sure it wouldn't be better to defer until we can update all of this according to your suggestion? |
|
I think we can move towards this iteratively. These changes don't break anything. And then we can remove all static methods that duplicate instance methods but only with a different return type. I just don't know how soon we will have inferring returned generic types |
|
Btw I tried do the same for For new signature: concat<U extends ArrayLike<T> = Array<T>>(other: U): U {
....
}UPD: |
StaticArray.slice/StaticArray.concatare quite not standard. Also, many users more expectStaticArrayas returning type insteadArrayforslicemethod. With this change, we preserve old behavior, so it's non breakable change.Open question:
What if change default return type from
ArraytoStaticArrayand removeStaticArray.sliceat all? This will be breaking change than.