You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use ArraySlice to strongly type Array#slice for known-length tuples, but realized that the current type returns empty arrays for -T['length'] < Start < 0 and -T['length'] < End < 0.
Given the type is stated to be based off of Array.slice, I feel it would make sense to implement such wraparound in the type system as well.
Note
This can be done with only externally-available types, but I feel the utility would make enough sense to warrant augmenting the existing type (and potentially a minor breaking change).
REMARKS
I think the easiest way to do this would be to simply move the existing logic to a helper type, and use a simple wrapper to adjust Start/End manually.
I wanted to use
ArraySliceto strongly typeArray#slicefor known-length tuples, but realized that the current type returns empty arrays for-T['length'] < Start < 0and-T['length'] < End < 0.Given the type is stated to be based off of
Array.slice, I feel it would make sense to implement such wraparound in the type system as well.Note
This can be done with only externally-available types, but I feel the utility would make enough sense to warrant augmenting the existing type (and potentially a minor breaking change).
REMARKS
I think the easiest way to do this would be to simply move the existing logic to a helper type, and use a simple wrapper to adjust
Start/Endmanually.Demonstrative TS Playground
I'd be willing to work on this if desired - the above link already has an (IMO) decently functional