Skip to content

ArraySlice should wrap around for -T['length'] < Start/End < 0 #1325

Description

@Bertie690

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.

Demonstrative TS Playground

I'd be willing to work on this if desired - the above link already has an (IMO) decently functional

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions